Fix memory allocation / free bugs.

This commit is contained in:
Danila Fedorin 2018-06-12 02:09:51 -07:00
parent 1438690b62
commit dc9702df4c

View File

@ -41,8 +41,7 @@ void _parser_extract_token_buffer(struct parser_state* state, char* buffer,
} }
int _parser_foreach_free_tree(void* data, va_list args) { int _parser_foreach_free_tree(void* data, va_list args) {
libab_tree_free(data); libab_tree_free_recursive(data);
free(data);
return 0; return 0;
} }
@ -1118,8 +1117,9 @@ libab_result _parse_expression(struct parser_state* state,
result = LIBAB_UNEXPECTED; result = LIBAB_UNEXPECTED;
} }
ll_free(&op_stack); ll_foreach(&op_stack, NULL, compare_always, _parser_foreach_free_tree);
ll_foreach(&out_stack, NULL, compare_always, _parser_foreach_free_tree); ll_foreach(&out_stack, NULL, compare_always, _parser_foreach_free_tree);
ll_free(&op_stack);
ll_free(&out_stack); ll_free(&out_stack);
return result; return result;