From 55542689f9bb1db9df1c8fc0ed860252264512ce Mon Sep 17 00:00:00 2001 From: Emden Gansner Date: Wed, 11 Jan 2012 17:35:49 -0500 Subject: [PATCH] Initialize static parsing data before parsing. On good graphs, this will be cleaned up 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/cgraph/grammar.y b/lib/cgraph/grammar.y index 5dfcc17d8..aa372a814 100644 --- a/lib/cgraph/grammar.y +++ b/lib/cgraph/grammar.y @@ -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; } -- 2.40.0