diff --git a/include/libregex.h b/include/libregex.h index e776d92..28339a5 100644 --- a/include/libregex.h +++ b/include/libregex.h @@ -301,7 +301,7 @@ void regex_node_clear(regex_node* node); * Frees an entire NFA, starting from the given root node. * @param root the root, or starting node, of the NFA. */ -void regex_free(regex_node* root); +libregex_result regex_free(regex_node* root); /** * Builds a regular expression from the given regular expression strings. * @param root the root node to build into. diff --git a/src/libregex.c b/src/libregex.c index fbfbc29..68eda3c 100644 --- a/src/libregex.c +++ b/src/libregex.c @@ -78,6 +78,7 @@ libregex_result _regex_node_create_group(regex_node** open, regex_node** close, } else { free(*open); free(*close); + *open = *close = NULL; } return result; } @@ -149,7 +150,7 @@ void _regex_chain_append_chain(regex_chain* append_to, regex_chain* to_append){ libregex_result _regex_find_all(regex_node* node, ll* append_to, int tag_with){ libregex_result result = LIBREGEX_SUCCESS; - if(node->list_id != tag_with){ + if(node && node->list_id != tag_with){ node->list_id = tag_with; if(node->type == REGEX_VALUE){ result = _regex_find_all(node->data_u.value_s.next, append_to, tag_with);