diff --git a/toml_parse.rl b/toml_parse.rl index 2d335e9..ee4348d 100644 --- a/toml_parse.rl +++ b/toml_parse.rl @@ -24,6 +24,7 @@ struct toml_stack_item { struct toml_stack_item* context = CONTEXT(&context_stack); \ list_del(&context->list); \ x = context->node; \ + free(context); \ } while (0) static size_t @@ -301,6 +302,7 @@ add_node_to_tree(struct list_head* context_stack, struct toml_node* node, char* context->list_type = TOML_LIST; item->node.type = TOML_LIST; + item->node.name = NULL; if (name) { item->node.name = name; @@ -769,6 +771,10 @@ toml_parse(struct toml_node* toml_root, char* buf, int buflen) %% write exec; + while ((root = CONTEXT(&context_stack))) { + POP_CONTEXT(toml_root); + } + if (malloc_error) { fprintf(stderr, "malloc failed, line %d\n", cur_line); return 1;