Code

frontend/parser: Don't override fields of unknown types.
authorSebastian Harl <sh@tokkee.org>
Fri, 17 Oct 2014 08:33:46 +0000 (10:33 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 17 Oct 2014 08:33:46 +0000 (10:33 +0200)
src/frontend/parser.c

index b0ae01a55bf618ee02f44e3098c290dec273c383..f16b71fd952a0bcc4c94c95c5d6eedb8d0dad21c 100644 (file)
@@ -115,12 +115,13 @@ sdb_fe_parse_matcher(const char *cond, int len)
        if (! node)
                return NULL;
 
-       if (node->cmd == CONNECTION_MATCHER)
+       if (node->cmd == CONNECTION_MATCHER) {
                m = CONN_MATCHER(node)->matcher;
+               CONN_MATCHER(node)->matcher = NULL;
+       }
        else
                m = NULL;
 
-       CONN_MATCHER(node)->matcher = NULL;
        sdb_llist_destroy(yyextra.parsetree);
        sdb_object_deref(SDB_OBJ(node));
        return m;
@@ -154,12 +155,13 @@ sdb_fe_parse_expr(const char *expr, int len)
        if (! node)
                return NULL;
 
-       if (node->cmd == CONNECTION_EXPR)
+       if (node->cmd == CONNECTION_EXPR) {
                e = CONN_EXPR(node)->expr;
+               CONN_EXPR(node)->expr = NULL;
+       }
        else
                e = NULL;
 
-       CONN_EXPR(node)->expr = NULL;
        sdb_llist_destroy(yyextra.parsetree);
        sdb_object_deref(SDB_OBJ(node));
        return e;