Merge branch 'garray_maxuint' into 'main'

garray: improve boundary checks

Closes #3240

See merge request GNOME/glib!3882
This commit is contained in:
Philip Withnall 2024-02-05 18:34:14 +00:00
commit 25e68476fa

View File

@ -878,6 +878,7 @@ g_array_remove_range (GArray *farray,
g_return_val_if_fail (array, NULL);
g_return_val_if_fail (index_ <= array->len, NULL);
g_return_val_if_fail (index_ <= G_MAXUINT - length, NULL);
g_return_val_if_fail (index_ + length <= array->len, NULL);
if (array->clear_func != NULL)
@ -2093,6 +2094,7 @@ g_ptr_array_remove_range (GPtrArray *array,
g_return_val_if_fail (rarray != NULL, NULL);
g_return_val_if_fail (rarray->len == 0 || (rarray->len != 0 && rarray->pdata != NULL), NULL);
g_return_val_if_fail (index_ <= rarray->len, NULL);
g_return_val_if_fail (index_ <= G_MAXUINT - length, NULL);
g_return_val_if_fail (length == 0 || index_ + length <= rarray->len, NULL);
if (length == 0)
@ -2972,6 +2974,7 @@ g_byte_array_remove_range (GByteArray *array,
{
g_return_val_if_fail (array, NULL);
g_return_val_if_fail (index_ <= array->len, NULL);
g_return_val_if_fail (index_ <= G_MAXUINT - length, NULL);
g_return_val_if_fail (index_ + length <= array->len, NULL);
return (GByteArray *)g_array_remove_range ((GArray *)array, index_, length);