[glib/bad-liststore: 2/2] list store: Fix overflow issues
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/bad-liststore: 2/2] list store: Fix overflow issues
- Date: Mon, 7 Jan 2019 13:53:58 +0000 (UTC)
commit d8a0dcb11e92d3237f5f4e90a4916df518bdc53d
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jan 6 14:17:30 2019 -0500
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
gio/gliststore.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gio/gliststore.c b/gio/gliststore.c
index ae8e2c1d8..8d87159d5 100644
--- a/gio/gliststore.c
+++ b/gio/gliststore.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]