diff --git a/src/runtime/stack.c b/src/runtime/stack.c index 55a124d6..5926ed78 100644 --- a/src/runtime/stack.c +++ b/src/runtime/stack.c @@ -26,7 +26,7 @@ struct StackNode { Length position; StackLink links[MAX_LINK_COUNT]; short unsigned int link_count; - short unsigned int ref_count; + uint32_t ref_count; unsigned error_cost; unsigned error_count; }; @@ -65,8 +65,9 @@ struct Stack { static void stack_node_retain(StackNode *self) { if (!self) return; - assert(self->ref_count != 0); + assert(self->ref_count > 0); self->ref_count++; + assert(self->ref_count != 0); } static void stack_node_release(StackNode *self, StackNodeArray *pool) { diff --git a/src/runtime/tree.c b/src/runtime/tree.c index c11843fb..92003ff1 100644 --- a/src/runtime/tree.c +++ b/src/runtime/tree.c @@ -232,6 +232,7 @@ Tree *ts_tree_make_error_node(TreeArray *children) { void ts_tree_retain(Tree *self) { assert(self->ref_count > 0); self->ref_count++; + assert(self->ref_count != 0); } void ts_tree_release(Tree *self) { diff --git a/src/runtime/tree.h b/src/runtime/tree.h index 8d1ce186..f5f23a9f 100644 --- a/src/runtime/tree.h +++ b/src/runtime/tree.h @@ -45,7 +45,7 @@ typedef struct Tree { TSLexMode lex_mode; } first_leaf; - unsigned short ref_count; + uint32_t ref_count; bool visible : 1; bool named : 1; bool extra : 1;