[glib/bad-liststore] gliststore: prevent overflow



commit 9446d0f354b45094427c45f7be9f80888b58638b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 6 14:17:30 2019 -0500

    gliststore: prevent overflow
    
    Check for over- and underflow when manipulating positions.
    
    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..050b9a8c2 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 != -1u && 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]