From 09ce2584c45f410069584b7f9db08c85c6b64ec5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 27 Nov 2017 19:23:10 +0000 Subject: [PATCH 5/9] 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. Signed-off-by: Simon McVittie --- test/test-utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test-utils.c b/test/test-utils.c index 843fda1a..53ad4a4e 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -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)) -- 2.15.0