From e8965dfead9f270ff8d7bb3029e86dee866d407d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Erdin=C3=A7=20K=C3=B6ro=C4=9Flu?= Date: Tue, 10 Oct 2023 14:17:04 +0300 Subject: [PATCH] There's a memory leak in yajl 2.1.0 with use of yajl_tree_parse function (#421) --- src/yajl/yajl_tree.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/yajl/yajl_tree.c b/src/yajl/yajl_tree.c index 1a05543..553a6fe 100644 --- a/src/yajl/yajl_tree.c +++ b/src/yajl/yajl_tree.c @@ -150,6 +150,7 @@ static yajl_val context_pop(context_t *ctx) v = stack->value; + free (stack->key); free (stack); return (v); @@ -455,7 +456,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; }