From b699040d41290d8a6858af323f178424993a5e3d Mon Sep 17 00:00:00 2001 From: Glen Low Date: Thu, 5 Dec 2013 17:18:20 +0800 Subject: [PATCH] Fix cascading failure when opening graphs * Lexer state needs to be flushed on failure to open. --- lib/cgraph/cghdr.h | 1 + lib/cgraph/grammar.y | 1 + lib/cgraph/scan.l | 2 ++ 3 files changed, 4 insertions(+) diff --git a/lib/cgraph/cghdr.h b/lib/cgraph/cghdr.h index 243dc1387..be7063e98 100644 --- a/lib/cgraph/cghdr.h +++ b/lib/cgraph/cghdr.h @@ -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, diff --git a/lib/cgraph/grammar.y b/lib/cgraph/grammar.y index b7d95dfc3..585df46b3 100644 --- a/lib/cgraph/grammar.y +++ b/lib/cgraph/grammar.y @@ -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; } diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index 2efd203cc..3efe1d5f4 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -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 -- 2.40.0