]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test_connection_setup: Don't crash on unlikely OOM
authorSimon McVittie <smcv@collabora.com>
Mon, 27 Nov 2017 19:23:10 +0000 (19:23 +0000)
committerSimon McVittie <smcv@collabora.com>
Mon, 4 Dec 2017 11:52:45 +0000 (11:52 +0000)
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>
test/test-utils.c

index 843fda1ac75ae608cbced56c37ec3d93007c686c..53ad4a4ea6e4cc8eda3aac705902a1c59e8f5698 100644 (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))