and there are subgraphs, dot_cleanup_graph assumes the subgraphs are bound to a Agraphinfo_t,
which doesn't exist. The calls to free the associated memory cause a crash.
The simplest solution is to check that Agraphinfo_t exists in dot_cleanup_graph before using it.
for (subg = agfstsubg(g); subg; subg = agnxtsubg(subg)) {
dot_cleanup_graph(subg);
}
+ if (! agbindrec(g, "Agraphinfo_t", 0, TRUE)) return;
if (GD_clust(g)) free (GD_clust(g));
if (GD_rankleader(g)) free (GD_rankleader(g));