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 <smcv@debian.org>

Closes: #559
Approved by: cgwalters
This commit is contained in:
Simon McVittie 2016-10-30 14:14:09 +00:00 committed by Atomic Bot
parent 213d5013ce
commit 4c32344b8e
1 changed files with 7 additions and 0 deletions

View File

@ -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);
}