[gnome-text-editor] textregionbtree: add more assertions and failure branching



commit 709f144d702915ce49c4c0dde21548d0f9880f41
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 19 11:07:46 2022 -0800

    textregionbtree: add more assertions and failure branching
    
    Related #296

 src/cjhtextregionbtree.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/cjhtextregionbtree.h b/src/cjhtextregionbtree.h
index 53609a6..610874c 100644
--- a/src/cjhtextregionbtree.h
+++ b/src/cjhtextregionbtree.h
@@ -191,7 +191,10 @@ G_BEGIN_DECLS
         for (_iter = (Node)->head, _nth = 0;                                 \
              _nth < (Nth);                                                   \
              _iter = (Node)->items[_iter].next, ++_nth)                      \
-          { /* Do Nothing */ }                                               \
+          {                                                                  \
+            /* Do Nothing */                                                 \
+            g_assert (_iter != VAL_QUEUE_INVALID(Node));                     \
+          }                                                                  \
       }                                                                      \
   } G_STMT_END
 #define _VAL_QUEUE_MOVE(Node, Old, New)                                      \
@@ -293,6 +296,12 @@ G_BEGIN_DECLS
     guint8 _len;                                                             \
                                                                              \
     VAL_QUEUE_POP_NTH(&(FIELD)->q, POSITION, _pos);                          \
+    if (_pos == VAL_QUEUE_INVALID(&(FIELD)->q))                              \
+      {                                                                      \
+        g_assert_not_reached ();                                             \
+        break;                                                               \
+      }                                                                      \
+                                                                             \
     _ele = (FIELD)->items[_pos];                                             \
     _len = VAL_QUEUE_LENGTH(&(FIELD)->q);                                    \
                                                                              \


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