mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-28 16:36:14 +01:00
gptrarray: Set free func on copied array in g_ptr_array_copy()
Otherwise its elements (which have just all been copied) will leak. Spotted by Xavier Claessens in https://gitlab.gnome.org/GNOME/glib/merge_requests/918#note_555867. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
d076c4c688
commit
1ac8d50331
@ -1020,6 +1020,9 @@ g_ptr_array_new (void)
|
|||||||
* If @func is %NULL, then only the pointers (and not what they are
|
* If @func is %NULL, then only the pointers (and not what they are
|
||||||
* pointing to) are copied to the new #GPtrArray.
|
* pointing to) are copied to the new #GPtrArray.
|
||||||
*
|
*
|
||||||
|
* The copy of @array will have the same #GDestroyNotify for its elements as
|
||||||
|
* @array.
|
||||||
|
*
|
||||||
* Returns: (transfer full): a deep copy of the initial #GPtrArray.
|
* Returns: (transfer full): a deep copy of the initial #GPtrArray.
|
||||||
*
|
*
|
||||||
* Since: 2.62
|
* Since: 2.62
|
||||||
@ -1035,6 +1038,8 @@ g_ptr_array_copy (GPtrArray *array,
|
|||||||
g_return_val_if_fail (array != NULL, NULL);
|
g_return_val_if_fail (array != NULL, NULL);
|
||||||
|
|
||||||
new_array = g_ptr_array_sized_new (array->len);
|
new_array = g_ptr_array_sized_new (array->len);
|
||||||
|
g_ptr_array_set_free_func (new_array, ((GRealPtrArray *) array)->element_free_func);
|
||||||
|
|
||||||
if (func != NULL)
|
if (func != NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; i < array->len; i++)
|
for (i = 0; i < array->len; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user