test_connection_setup: Don't crash on unlikely OOM

If _dbus_loop_queue_dispatch fails with OOM, we'd try to free cd,
while cd is already owned by the connection's timeout functions.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100317
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2017-11-27 19:23:10 +00:00
parent 929c15c797
commit 38ff6bd20d

View file

@ -108,7 +108,8 @@ test_connection_setup (TestMainContext *ctx,
dbus_connection_set_dispatch_status_function (connection, dispatch_status_function,
loop, NULL);
/* ownership of cd taken */
cd = cdata_new (loop, connection);
if (cd == NULL)
goto nomem;
@ -132,6 +133,9 @@ test_connection_setup (TestMainContext *ctx,
cd, cdata_free))
goto nomem;
/* ownership taken */
cd = NULL;
if (dbus_connection_get_dispatch_status (connection) != DBUS_DISPATCH_COMPLETE)
{
if (!_dbus_loop_queue_dispatch (loop, connection))