Update copyright
[oweals/jsonpath.git] / parser.y
index e3b9ee989e489ff6c61674cfd77d5ae153448f5f..513fea608ca86cac5acac44d7a917b941ce9d755 100644 (file)
--- a/parser.y
+++ b/parser.y
@@ -1,6 +1,6 @@
 %{
 /*
- * Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
+ * Copyright (C) 2013-2014 Jo-Philipp Wich <jow@openwrt.org>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -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);
 }