diff --git a/src/cdogs/yajl/yajl_tree.c b/src/cdogs/yajl/yajl_tree.c index 22e666cce..977a7bc1b 100644 --- a/src/cdogs/yajl/yajl_tree.c +++ b/src/cdogs/yajl/yajl_tree.c @@ -143,7 +143,7 @@ static yajl_val context_pop(context_t *ctx) ctx->stack = stack->next; v = stack->value; - + free (stack->key); free (stack); return (v); @@ -444,7 +444,14 @@ yajl_val yajl_tree_parse (const char *input, snprintf(error_buffer, error_buffer_size, "%s", internal_err_str); YA_FREE(&(handle->alloc), internal_err_str); } + while(ctx.stack != NULL) { + yajl_val v = context_pop(&ctx); + yajl_tree_free(v); + } yajl_free (handle); + //If the requested memory is not released in time, it will cause memory leakage + if(ctx.root) + yajl_tree_free(ctx.root); return NULL; }