initrd: fix memory leak

Signed-off-by: Antonio Cardace <acardace@redhat.com>
Fixes: 9f9609555d ('initrd: add configuration generator')
(cherry picked from commit d5c05d07c7)
(cherry picked from commit bba54613eb)
(cherry picked from commit 67bb9896b3)
(cherry picked from commit 5913e4cee9)
(cherry picked from commit 9ed8b871bb)
This commit is contained in:
Antonio Cardace 2020-09-01 18:38:45 +02:00 committed by Thomas Haller
parent dc94723ad8
commit 8d37bb0d3a
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 9 additions and 1 deletions

View file

@ -232,6 +232,14 @@ NM_AUTO_DEFINE_FCN0 (GError *, gs_local_free_error, g_error_free)
#define gs_unref_keyfile nm_auto(gs_local_keyfile_unref)
NM_AUTO_DEFINE_FCN0 (GKeyFile *, gs_local_keyfile_unref, g_key_file_unref)
/**
* gs_free_option_context:
*
* Call g_option_context_free() on a variable location when it goes out of scope.
*/
#define gs_free_option_context nm_auto(gs_local_option_context)
NM_AUTO_DEFINE_FCN0 (GOptionContext *, gs_local_option_context, g_option_context_free);
/*****************************************************************************/
#include "nm-glib.h"

View file

@ -90,7 +90,7 @@ main (int argc, char *argv[])
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, NULL },
{ NULL }
};
GOptionContext *option_context;
gs_free_option_context GOptionContext *option_context = NULL;
GError *error = NULL;
int errsv;