[gtk/static-analysis-fixes: 3/4] listitemmanager: Add a few assertions




commit 295d40620731d89bcdcfaf0c80f748654a730d27
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Sep 17 22:03:56 2021 -0400

    listitemmanager: Add a few assertions
    
    This might help poor static analyzers.

 gtk/gtklistitemmanager.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtklistitemmanager.c b/gtk/gtklistitemmanager.c
index 5f263b24ab..1a0ff55161 100644
--- a/gtk/gtklistitemmanager.c
+++ b/gtk/gtklistitemmanager.c
@@ -443,6 +443,7 @@ gtk_list_item_manager_release_items (GtkListItemManager *self,
       i = position - i;
       while (i < position + query_n_items)
         {
+          g_assert (item != NULL);
           if (item->widget)
             {
               g_queue_push_tail (released, item->widget);
@@ -459,7 +460,7 @@ gtk_list_item_manager_release_items (GtkListItemManager *self,
                     g_assert_not_reached ();
                   item = gtk_rb_tree_node_get_next (next);
                 }
-              else 
+              else
                 {
                   item = next;
                 }
@@ -511,6 +512,7 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
 
       if (offset > 0)
         {
+          g_assert (item != NULL);
           new_item = gtk_rb_tree_insert_before (self->items, item);
           new_item->n_items = offset;
           item->n_items -= offset;
@@ -519,6 +521,7 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
 
       for (i = 0; i < query_n_items; i++)
         {
+          g_assert (item != NULL);
           if (item->n_items > 1)
             {
               new_item = gtk_rb_tree_insert_before (self->items, item);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]