mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
GOption: fix bug in strv mode
We are a bit too aggressive about freeing memory in strv mode. Only free it in the case that we actually set the pointer to NULL. Uncovered by the GApplication tests.
This commit is contained in:
parent
6939add283
commit
7f36233042
@ -1717,9 +1717,6 @@ free_pending_nulls (GOptionContext *context,
|
||||
|
||||
if (perform_nulls)
|
||||
{
|
||||
if (context->strv_mode)
|
||||
g_free (*n->ptr);
|
||||
|
||||
if (n->value)
|
||||
{
|
||||
/* Copy back the short options */
|
||||
@ -1727,7 +1724,12 @@ free_pending_nulls (GOptionContext *context,
|
||||
strcpy (*n->ptr + 1, n->value);
|
||||
}
|
||||
else
|
||||
*n->ptr = NULL;
|
||||
{
|
||||
if (context->strv_mode)
|
||||
g_free (*n->ptr);
|
||||
|
||||
*n->ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (n->value);
|
||||
|
Loading…
Reference in New Issue
Block a user