diff --git a/src/prio.c b/src/prio.c index 1b8e714..f0a1432 100644 --- a/src/prio.c +++ b/src/prio.c @@ -10,7 +10,6 @@ #include #include - static void prio__free(cleri_t * cl_obj); static cleri_node_t * prio__parse( @@ -123,6 +122,12 @@ static cleri_node_t * prio__parse( { if (tested->node != NULL) { + /* + * It is required to decrement an extra reference here, one + * belongs to the parse result, and one for the tested rule. + * The node->ref increment below is required for when a str + * position is visited a second time by another parent. + */ --tested->node->ref; cleri__node_free(tested->node); } diff --git a/test/test_thingsdb_lang/test_thingsdb_lang.c b/test/test_thingsdb_lang/test_thingsdb_lang.c index 0bdbb51..39540ef 100644 --- a/test/test_thingsdb_lang/test_thingsdb_lang.c +++ b/test/test_thingsdb_lang/test_thingsdb_lang.c @@ -316,7 +316,7 @@ static int test_thingsdb_lang(void) _assert_is_valid (grammar, "x = 1"); _assert_is_valid (grammar, "||1?2:3"); - _assert_is_not_valid (grammar, "||1?2" ); + _assert_is_not_valid (grammar, "||1?2"); cleri_grammar_free(grammar);