mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
gvariant-serialiser: Check offsets array is initialised before using it
When piecewise validating the offset table for a variable sized array, it’s possible that the offset table (`offsets.array`) won’t actually have been set by `gvs_variable_sized_array_get_frame_offsets()` iff the serialised `GVariant` is not in normal form. Add an additional check to guard against this. This will result in an empty child variant being returned, as with other error handling paths in `gvs_variable_sized_array_get_child()`. This is a true positive spotted by scan-build. Thanks, scan-build. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #1767
This commit is contained in:
parent
4b7f6ffe4c
commit
0814be8bef
@ -762,7 +762,8 @@ gvs_variable_sized_array_get_child (GVariantSerialised value,
|
||||
* Don’t bother checking if the highest known-good offset is lower than the
|
||||
* highest checked offset, as that means there’s an invalid element at that
|
||||
* index, so there’s no need to check further. */
|
||||
if (index_ > value.checked_offsets_up_to &&
|
||||
if (offsets.array != NULL &&
|
||||
index_ > value.checked_offsets_up_to &&
|
||||
value.ordered_offsets_up_to == value.checked_offsets_up_to)
|
||||
{
|
||||
switch (offsets.offset_size)
|
||||
|
Loading…
Reference in New Issue
Block a user