mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-20 22:29:17 +02:00
g_data_set_internal: avoid use-after-free if datalist is in dataset
Removing the last thing in a dataset frees the dataset, and if the datalist was in a dataset, we can't safely unlock it after the dataset has been freed. Unlock it sooner. Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113 Reviewed-by: Matthias Clasen <mclasen@redhat.com>
This commit is contained in:
parent
0bf8378840
commit
c49a4dba82
@ -387,6 +387,10 @@ g_data_set_internal (GData **datalist,
|
|||||||
{
|
{
|
||||||
G_DATALIST_SET_POINTER (datalist, NULL);
|
G_DATALIST_SET_POINTER (datalist, NULL);
|
||||||
g_free (d);
|
g_free (d);
|
||||||
|
/* datalist may be situated in dataset, so must not be
|
||||||
|
* unlocked after we free it
|
||||||
|
*/
|
||||||
|
g_datalist_unlock (datalist);
|
||||||
|
|
||||||
/* the dataset destruction *must* be done
|
/* the dataset destruction *must* be done
|
||||||
* prior to invocation of the data destroy function
|
* prior to invocation of the data destroy function
|
||||||
@ -394,8 +398,10 @@ g_data_set_internal (GData **datalist,
|
|||||||
if (dataset)
|
if (dataset)
|
||||||
g_dataset_destroy_internal (dataset);
|
g_dataset_destroy_internal (dataset);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
g_datalist_unlock (datalist);
|
{
|
||||||
|
g_datalist_unlock (datalist);
|
||||||
|
}
|
||||||
|
|
||||||
/* We found and removed an old value
|
/* We found and removed an old value
|
||||||
* the GData struct *must* already be unlinked
|
* the GData struct *must* already be unlinked
|
||||||
|
Loading…
x
Reference in New Issue
Block a user