From d7eb78ffc3ec17ccbcc0f83288a01ccfe6ac51e5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 9 Nov 2015 13:38:59 +0100 Subject: [PATCH 2/2] Fix memory leaks in bus_activation_service_reload_test() in case of errors. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92721 --- bus/activation.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index 3c3bd7a..7b1ab06 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -2593,6 +2593,7 @@ bus_activation_service_reload_test (const DBusString *test_data_dir) { DBusString directory; const char *tmp; + dbus_bool_t ret = FALSE; if (!_dbus_string_init (&directory)) return FALSE; @@ -2600,16 +2601,14 @@ bus_activation_service_reload_test (const DBusString *test_data_dir) tmp = _dbus_get_tmpdir (); if (tmp == NULL) - return FALSE; + goto out; if (!_dbus_string_append (&directory, tmp)) - return FALSE; + goto out; if (!_dbus_string_append (&directory, "/dbus-reload-test-") || !_dbus_generate_random_ascii (&directory, 6, NULL)) - { - return FALSE; - } + goto out; /* Do normal tests */ if (!init_service_reload_test (&directory)) @@ -2631,11 +2630,13 @@ bus_activation_service_reload_test (const DBusString *test_data_dir) /* Cleanup test directory */ if (!cleanup_service_reload_test (&directory)) - return FALSE; + goto out; - _dbus_string_free (&directory); + ret = TRUE; - return TRUE; +out: + _dbus_string_free (&directory); + return ret; } #endif /* DBUS_ENABLE_EMBEDDED_TESTS */ -- 1.8.4.5