]> granicus.if.org Git - graphviz/commitdiff
Fix cascading failure when opening graphs
authorGlen Low <glen.low@pixelglow.com>
Thu, 5 Dec 2013 09:18:20 +0000 (17:18 +0800)
committerGlen Low <glen.low@pixelglow.com>
Thu, 5 Dec 2013 09:18:20 +0000 (17:18 +0800)
* Lexer state needs to be flushed on failure to open.

lib/cgraph/cghdr.h
lib/cgraph/grammar.y
lib/cgraph/scan.l

index 243dc138791074f996a2ca80413917b8044ab47c..be7063e982d4c4e0a422a6a5a986dc61166a3904 100644 (file)
@@ -142,6 +142,7 @@ int aagparse(void);
 void aglexinit(Agdisc_t * disc, void *ifile);
 int aaglex(void);
 void aglexeof(void);
+void aglexbad(void);
 
        /* ID management */
 int agmapnametoid(Agraph_t * g, int objtype, char *str,
index b7d95dfc3fd8256ae3a8e7138a1c487aac1268ff..585df46b32f7ce29fc0d76f084b509ac89ce142e 100644 (file)
@@ -580,6 +580,7 @@ Agraph_t *agconcat(Agraph_t *g, void *chan, Agdisc_t *disc)
        Disc = (disc? disc :  &AgDefaultDisc);
        aglexinit(Disc, chan);
        yyparse();
+       if (Ag_G_global == NILgraph) aglexbad();
        return Ag_G_global;
 }
 
index 2efd203cce1bcffeed860100f15776f75ef8daef..3efe1d5f4ade3e24ed85032b1753cb9c00ddc384 100644 (file)
@@ -211,6 +211,8 @@ void yyerror(char *str)
 /* must be here to see flex's macro defns */
 void aglexeof() { unput(GRAPH_EOF_TOKEN); }
 
+void aglexbad() { YY_FLUSH_BUFFER; }
+
 #ifndef YY_CALL_ONLY_ARG
 # define YY_CALL_ONLY_ARG void
 #endif