summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2015-07-28 07:42:56 +0200
committerMartin Pitt <martin.pitt@ubuntu.com>2015-07-28 07:42:56 +0200
commit410cab8f3d749ad2660cda3ba38b6aece42bf10f (patch)
tree87ccd8ac6967df3285be4715e7c502eaeb84a106
parent95055d10a6709b0d6dc73a4b5152708a40405588 (diff)
downloadudisks-410cab8f3d749ad2660cda3ba38b6aece42bf10f.tar.gz
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
-rw-r--r--tools/udisksctl.c9
1 files 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);
}