From: Jo-Philipp Wich Date: Wed, 1 Jan 2014 21:39:23 +0000 (+0000) Subject: parser: fix error reporting X-Git-Url: https://git.librecmc.org/?p=oweals%2Fjsonpath.git;a=commitdiff_plain;h=98e332ea671108d34b4b2fd2cde7ba9d478b3e27 parser: fix error reporting --- diff --git a/parser.y b/parser.y index e3b9ee9..54c6077 100644 --- a/parser.y +++ b/parser.y @@ -58,7 +58,7 @@ struct jp_opcode { struct jp_state { struct jp_opcode *pool; struct jp_opcode *path; - const char *error; + char *error; char str_quote; char str_buf[128]; char *str_ptr; @@ -167,7 +167,7 @@ unary_exp void yyerror(struct jp_state *s, const char *msg) { - s->error = msg; + s->error = strdup(msg); } static struct jp_opcode * @@ -253,5 +253,8 @@ jp_free(struct jp_state *s) op = tmp; } + if (s->error) + free(s->error); + free(s); }