parser: fix error reporting
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 1 Jan 2014 21:39:23 +0000 (21:39 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 1 Jan 2014 21:53:09 +0000 (21:53 +0000)
parser.y

index e3b9ee989e489ff6c61674cfd77d5ae153448f5f..54c60779bda346f22f6540869e9551030d376b0e 100644 (file)
--- 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);
 }