From 709f144d702915ce49c4c0dde21548d0f9880f41 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 19 Jan 2022 11:07:46 -0800 Subject: [PATCH] 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); \ \ -- GitLab