Commit d8a0dcb1 authored by Matthias Clasen's avatar Matthias Clasen

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
parent 471153fb
Pipeline #49620 passed with stages
in 14 minutes and 20 seconds
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment