mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
Merge branch 'coverity-array-fixes' into 'main'
garray: Add assertions to help static analysis See merge request GNOME/glib!3097
This commit is contained in:
commit
dddfdb8488
@ -285,6 +285,7 @@ g_array_sized_new (gboolean zero_terminated,
|
|||||||
if (array->zero_terminated || reserved_size != 0)
|
if (array->zero_terminated || reserved_size != 0)
|
||||||
{
|
{
|
||||||
g_array_maybe_expand (array, reserved_size);
|
g_array_maybe_expand (array, reserved_size);
|
||||||
|
g_assert (array->data != NULL);
|
||||||
g_array_zero_terminate (array);
|
g_array_zero_terminate (array);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1120,7 +1121,10 @@ ptr_array_new (guint reserved_size,
|
|||||||
if (G_LIKELY (reserved_size < G_MAXUINT) &&
|
if (G_LIKELY (reserved_size < G_MAXUINT) &&
|
||||||
null_terminated)
|
null_terminated)
|
||||||
reserved_size++;
|
reserved_size++;
|
||||||
|
|
||||||
g_ptr_array_maybe_expand (array, reserved_size);
|
g_ptr_array_maybe_expand (array, reserved_size);
|
||||||
|
g_assert (array->pdata != NULL);
|
||||||
|
|
||||||
if (null_terminated)
|
if (null_terminated)
|
||||||
{
|
{
|
||||||
/* don't use ptr_array_maybe_null_terminate(). It helps the compiler
|
/* don't use ptr_array_maybe_null_terminate(). It helps the compiler
|
||||||
|
Loading…
Reference in New Issue
Block a user