Skip to content

Commit

Permalink
[jv_parse] Fix a leak in value when a val wasn't freed if the funct…
Browse files Browse the repository at this point in the history
…ion error-ed.
  • Loading branch information
Leonid S. Usov committed Oct 22, 2018
1 parent f585fcc commit 401817b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/jv_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,19 @@ static void parser_free(struct jv_parser* p) {

static pfunc value(struct jv_parser* p, jv val) {
if ((p->flags & JV_PARSE_STREAMING)) {
if (jv_is_valid(p->next) || p->last_seen == JV_LAST_VALUE)
if (jv_is_valid(p->next) || p->last_seen == JV_LAST_VALUE) {
jv_free(val);
return "Expected separator between values";
}
if (p->stacklen > 0)
p->last_seen = JV_LAST_VALUE;
else
p->last_seen = JV_LAST_NONE;
} else {
if (jv_is_valid(p->next)) return "Expected separator between values";
if (jv_is_valid(p->next)) {
jv_free(val);
return "Expected separator between values";
}
}
jv_free(p->next);
p->next = val;
Expand Down

0 comments on commit 401817b

Please sign in to comment.