Fix two bugs. One was caused by the previous commit.

The other was created by using invalid memory.
This commit is contained in:
Danila Fedorin 2017-02-25 22:38:13 -08:00
parent c629be5d68
commit eb4204fe76

View File

@ -328,7 +328,7 @@ liblex_result _pattern_build_chain(pattern_chain** into, int* ids, int pattern_i
result = _pattern_chain_create(&current_chain, NULL, NULL); result = _pattern_chain_create(&current_chain, NULL, NULL);
(*index)++; (*index)++;
} }
} if(string[*index] == '.') { } else if(string[*index] == '.') {
pattern_node* new_node = NULL; pattern_node* new_node = NULL;
_pattern_chain_append_chain_discard(current_chain, &sub_chain); _pattern_chain_append_chain_discard(current_chain, &sub_chain);
result = _pattern_chain_create(&sub_chain, NULL, NULL); result = _pattern_chain_create(&sub_chain, NULL, NULL);
@ -438,6 +438,8 @@ liblex_result pattern_compile(pattern* ptrn, char* expression, int id){
ptrn->size = ids + 1; ptrn->size = ids + 1;
free(full_chain); free(full_chain);
} else { } else {
ptrn->head = NULL;
ptrn->size = 0;
if(full_chain){ if(full_chain){
_pattern_free(full_chain->head, ids); _pattern_free(full_chain->head, ids);
} }