From 1e16eb92948654ca4ab34f84c60527dfc495fb0a Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 26 Apr 2016 17:28:14 -0700 Subject: [PATCH] Don't leak whatever is left of one parse tree when starting another --- jsonpull.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jsonpull.c b/jsonpull.c index 296b7b63..ccc9c821 100644 --- a/jsonpull.c +++ b/jsonpull.c @@ -180,6 +180,10 @@ static json_object *add_object(json_pull *j, json_type type) { } } } else { + if (j->root != NULL) { + json_free(j->root); + } + j->root = o; } @@ -272,6 +276,10 @@ json_object *json_read_separators(json_pull *j, json_separator_callback cb, void // In case there is an error at the top level if (j->container == NULL) { + if (j->root != NULL) { + json_free(j->root); + } + j->root = NULL; }