Merge branch 'wip/smcv/array-memcpy-ub' into 'master'

array: Avoid use of memcpy(dest, NULL, 0)

See merge request GNOME/glib!1180
This commit is contained in:
Sebastian Dröge 2019-10-24 11:49:09 +00:00
commit 05be19b9f7

View File

@ -1146,7 +1146,7 @@ g_ptr_array_copy (GPtrArray *array,
for (i = 0; i < array->len; i++)
new_array->pdata[i] = func (array->pdata[i], user_data);
}
else
else if (array->len > 0)
{
memcpy (new_array->pdata, array->pdata,
array->len * sizeof (*array->pdata));
@ -1797,7 +1797,7 @@ g_ptr_array_extend (GPtrArray *array_to_extend,
rarray_to_extend->pdata[i + rarray_to_extend->len] =
func (array->pdata[i], user_data);
}
else
else if (array->len > 0)
{
memcpy (rarray_to_extend->pdata + rarray_to_extend->len, array->pdata,
array->len * sizeof (*array->pdata));