From 4c32344b8e71e40034fcdbf3053f46c290fac785 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 30 Oct 2016 14:14:09 +0000 Subject: [PATCH] ostree_admin_option_context_parse: explicitly clean up when exiting early The cleanup attribute doesn't clean up before calling a noreturn function like exit(). Explicitly clean up the pointer variables (but don't assume that a simple g_object_unref() would be OK either, in case the behaviour of the cleanup attribute changes). This isn't a real leak since we're about to exit anyway, but if we don't fix it then valgrind memcheck will make the tests fail. Signed-off-by: Simon McVittie Closes: #559 Approved by: cgwalters --- src/ostree/ot-main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index 18c13239..5080e8c6 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -366,6 +366,13 @@ ostree_admin_option_context_parse (GOptionContext *context, g_print ("%s\n", deployment_path); + /* The g_autoptr, g_autofree etc. don't happen when we explicitly + * exit, making valgrind complain about leaks */ + g_clear_object (&sysroot); + g_clear_object (&sysroot_path); + g_clear_object (&deployment_file); + g_clear_pointer (&deployments, g_ptr_array_unref); + g_clear_pointer (&deployment_path, g_free); exit (EXIT_SUCCESS); }