]> granicus.if.org Git - graphviz/commitdiff
Initialize static parsing data before parsing. On good graphs, this will be cleaned up
authorEmden Gansner <erg@research.att.com>
Wed, 11 Jan 2012 22:35:49 +0000 (17:35 -0500)
committerEmden Gansner <erg@research.att.com>
Wed, 11 Jan 2012 22:35:49 +0000 (17:35 -0500)
at the end, but on error, the data is left pointing to graph data that has been freed,
causing a subsequent parse to crash.

lib/cgraph/grammar.y

index 5dfcc17d8e702e6a5faeb5557e3b65d7450145b2..aa372a81438ba3a99e1a88c2a36e0b87c6d2da61 100644 (file)
@@ -227,6 +227,11 @@ static void delete_items(item *ilist)
        }
 }
 
+static void initlist(list_t *list)
+{
+       list->first = list->last = NILitem;
+}
+
 static void deletelist(list_t *list)
 {
        delete_items(list->first);
@@ -537,6 +542,9 @@ Agraph_t *agconcat(Agraph_t *g, void *chan, Agdisc_t *disc)
        Ag_G_global = NILgraph;
        Disc = (disc? disc :  &AgDefaultDisc);
        aglexinit(Disc, chan);
+       initlist(&Attrlist);
+       initlist(&Nodelist);
+       initlist(&Edgelist);
        yyparse();
        return Ag_G_global;
 }