mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-13 04:46:15 +01:00
goption: Add a precondition to avoid GOptionEntry list overflow
If the calling code adds more option entries than `G_MAXSIZE` then there’ll be an integer overflow. This seems vanishingly unlikely (given that all callers use static option entry lists), but add a precondition anyway. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #2197
This commit is contained in:
parent
bdcf193c2e
commit
63c5b62f0a
@ -2422,6 +2422,8 @@ g_option_group_add_entries (GOptionGroup *group,
|
||||
|
||||
for (n_entries = 0; entries[n_entries].long_name != NULL; n_entries++) ;
|
||||
|
||||
g_return_if_fail (n_entries <= G_MAXSIZE - group->n_entries);
|
||||
|
||||
group->entries = g_renew (GOptionEntry, group->entries, group->n_entries + n_entries);
|
||||
|
||||
/* group->entries could be NULL in the trivial case where we add no
|
||||
|
Loading…
Reference in New Issue
Block a user