mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 23:16:14 +01:00
gdataset: Preserve destruction order
In `g_data_remove_internal()`, call the `GDataElt:destroy` functions in the order that they appear in `keys`, instead of the order that they are found in `datalist`. Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2672
This commit is contained in:
parent
ac113c1ed2
commit
a4fa456e67
@ -504,7 +504,7 @@ g_data_remove_internal (GData **datalist,
|
||||
GDataElt *old, *data, *data_end;
|
||||
gsize found_keys;
|
||||
|
||||
old = g_newa (GDataElt, n_keys);
|
||||
old = g_newa0 (GDataElt, n_keys);
|
||||
|
||||
data = d->data;
|
||||
data_end = data + d->len;
|
||||
@ -518,6 +518,7 @@ g_data_remove_internal (GData **datalist,
|
||||
{
|
||||
if (data->key == keys[i])
|
||||
{
|
||||
old[i] = *data;
|
||||
remove = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -525,7 +526,6 @@ g_data_remove_internal (GData **datalist,
|
||||
|
||||
if (remove)
|
||||
{
|
||||
old[found_keys] = *data;
|
||||
found_keys++;
|
||||
|
||||
if (data < --data_end)
|
||||
@ -553,7 +553,7 @@ g_data_remove_internal (GData **datalist,
|
||||
{
|
||||
g_datalist_unlock (datalist);
|
||||
|
||||
for (gsize i = 0; i < found_keys; i++)
|
||||
for (gsize i = 0; i < n_keys; i++)
|
||||
{
|
||||
if (old[i].destroy)
|
||||
old[i].destroy (old[i].data);
|
||||
|
Loading…
Reference in New Issue
Block a user