Don't leak whatever is left of one parse tree when starting another

This commit is contained in:
Eric Fischer 2016-04-26 17:28:14 -07:00
parent 39c180a673
commit 1e16eb9294

View File

@ -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;
}