mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 17:56:17 +01:00
list store: Fix overflow issues
Check for over- and underflow when manipulating positions. This makes the sequence g_list_model_get_item (store, 0); g_list_model_get_item (store, -1u); return NULL for the second call, as it should. Closes: #1639
This commit is contained in:
parent
471153fb20
commit
d8a0dcb11e
@ -181,9 +181,9 @@ g_list_store_get_item (GListModel *list,
|
||||
|
||||
if (store->last_position != -1u)
|
||||
{
|
||||
if (store->last_position == position + 1)
|
||||
if (position < G_MAXUINT && store->last_position == position + 1)
|
||||
it = g_sequence_iter_prev (store->last_iter);
|
||||
else if (store->last_position == position - 1)
|
||||
else if (position > 0 && store->last_position == position - 1)
|
||||
it = g_sequence_iter_next (store->last_iter);
|
||||
else if (store->last_position == position)
|
||||
it = store->last_iter;
|
||||
|
Loading…
Reference in New Issue
Block a user