mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
goption: Don't return pointers to deallocated memory
g_option_context_parse() can return pointers to deallocated strings, if the command line contains an unknown option. https://bugzilla.gnome.org/show_bug.cgi?id=646926
This commit is contained in:
parent
7bf31065cc
commit
b12e0b8869
@ -1281,9 +1281,12 @@ parse_arg (GOptionContext *context,
|
||||
|
||||
change = get_change (context, G_OPTION_ARG_STRING,
|
||||
entry->arg_data);
|
||||
g_free (change->allocated.str);
|
||||
|
||||
change->prev.str = *(gchar **)entry->arg_data;
|
||||
if (!change->allocated.str)
|
||||
change->prev.str = *(gchar **)entry->arg_data;
|
||||
else
|
||||
g_free (change->allocated.str);
|
||||
|
||||
change->allocated.str = data;
|
||||
|
||||
*(gchar **)entry->arg_data = data;
|
||||
@ -1345,9 +1348,12 @@ parse_arg (GOptionContext *context,
|
||||
#endif
|
||||
change = get_change (context, G_OPTION_ARG_FILENAME,
|
||||
entry->arg_data);
|
||||
g_free (change->allocated.str);
|
||||
|
||||
change->prev.str = *(gchar **)entry->arg_data;
|
||||
if (!change->allocated.str)
|
||||
change->prev.str = *(gchar **)entry->arg_data;
|
||||
else
|
||||
g_free (change->allocated.str);
|
||||
|
||||
change->allocated.str = data;
|
||||
|
||||
*(gchar **)entry->arg_data = data;
|
||||
|
Loading…
Reference in New Issue
Block a user