]> granicus.if.org Git - graphviz/commitdiff
Fix parser so that it guarantees the precondition S = G = NULL and postcondition...
authorEmden Gansner <emdenrg@google.com>
Thu, 21 Apr 2016 16:04:55 +0000 (12:04 -0400)
committerEmden Gansner <emdenrg@google.com>
Thu, 21 Apr 2016 16:04:55 +0000 (12:04 -0400)
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.

lib/cgraph/grammar.y

index b43f493a95d9b12d01a353bd8dd0b97162606ca1..2f3f807bbc600bd32d0cbd45c0fc69f741e0e323 100644 (file)
@@ -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 */
                        ;