From 410cab8f3d749ad2660cda3ba38b6aece42bf10f Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 28 Jul 2015 07:42:56 +0200 Subject: Fix udiskctl help for glib 2.45 glib 2.45 now requires calling g_option_context_add_main_entries(), otherwise it crashes on a NULL OptionContext->main_group. Don't prematurely free the description as g_option_context_set_description() does not copy the string. https://launchpad.net/bugs/1478369 --- tools/udisksctl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/udisksctl.c b/tools/udisksctl.c index e715440..2456a96 100644 --- a/tools/udisksctl.c +++ b/tools/udisksctl.c @@ -3070,15 +3070,18 @@ static void usage (gint *argc, gchar **argv[], gboolean use_stdout) { GOptionContext *o; + static GOptionEntry entries[] = { { NULL } }; + gchar *description; gchar *s; gchar *program_name; o = g_option_context_new ("COMMAND"); g_option_context_set_help_enabled (o, FALSE); + g_option_context_add_main_entries (o, entries, NULL); /* Ignore parsing result */ g_option_context_parse (o, argc, argv, NULL); program_name = g_path_get_basename ((*argv)[0]); - s = g_strdup_printf ("Commands:\n" + description = g_strdup_printf ("Commands:\n" " help Shows this information\n" " info Shows information about an object\n" " dump Shows information about all objects\n" @@ -3096,14 +3099,14 @@ usage (gint *argc, gchar **argv[], gboolean use_stdout) "Use \"%s COMMAND --help\" to get help on each command.\n", program_name); g_free (program_name); - g_option_context_set_description (o, s); - g_free (s); + g_option_context_set_description (o, description); s = g_option_context_get_help (o, FALSE, NULL); if (use_stdout) g_print ("%s", s); else g_printerr ("%s", s); g_free (s); + g_free (description); g_option_context_free (o); } -- cgit v1.2.3