From: Emden Gansner Date: Thu, 21 Apr 2016 16:04:55 +0000 (-0400) Subject: Fix parser so that it guarantees the precondition S = G = NULL and postcondition... X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~19^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce6effe7da8f0450eff9e7ad21b9e8ec5e04d969;p=graphviz Fix parser so that it guarantees the precondition S = G = NULL and postcondition S = NULL and G is a valid graph on success and G = NULL on error. We need to clean the stack in all cases to prevent a small memory leak. Note that if S starts as NULL and is non-NULL at the end, then in G is non-NULL. --- diff --git a/lib/cgraph/grammar.y b/lib/cgraph/grammar.y index b43f493a9..2f3f807bb 100644 --- a/lib/cgraph/grammar.y +++ b/lib/cgraph/grammar.y @@ -95,8 +95,8 @@ static gstack_t *S; %% -graph : hdr body {endgraph();} - | error {freestack(); if (G) {endgraph(); agclose(G); G = Ag_G_global = NIL(Agraph_t*);}} +graph : hdr body {freestack(); endgraph();} + | error {if (G) {freestack(); endgraph(); agclose(G); G = Ag_G_global = NIL(Agraph_t*);}} | /* empty */ ;