From 396610d14aba0cd03b8daa08569a70266ce4e454 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Sun, 20 Jul 2014 08:47:32 -0400 Subject: [PATCH] libnm-glib: fix assertion-failure messages in test-remote-settings-client test-remote-setting-client uses a macro: #define test_assert(condition) \ do { \ if (!G_LIKELY (condition)) \ cleanup (); \ g_assert (condition); \ } while (0) where cleanup() kills the fake remote-settings service and unrefs settings. However, in many cases, "condition" would involve a test against a connection that was owned by settings, so if the check failed, the connection would end up getting freed by cleanup(), and so then the second invocation of condition would result in the program aborting on a failed check somewhere else (eg, "invalid unclassed pointer in cast to 'NMConnection'") rather than displaying the failed assertion that had gotten us to that point. Fix this by not unreffing settings from cleanup(); in the normal exit case we can just have main() unref it, and in the assertion-failed case, we don't need to free things anyway. --- libnm-glib/tests/test-remote-settings-client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c index d92583a112..970ba73ced 100644 --- a/libnm-glib/tests/test-remote-settings-client.c +++ b/libnm-glib/tests/test-remote-settings-client.c @@ -44,8 +44,6 @@ NMRemoteConnection *remote = NULL; static void cleanup (void) { - if (settings) - g_object_unref (settings); kill (spid, SIGTERM); } @@ -392,6 +390,7 @@ main (int argc, char **argv) ret = g_test_run (); cleanup (); + g_object_unref (settings); dbus_g_connection_unref (bus); return ret;