From: Magnus Jacobsson Date: Wed, 13 Jul 2022 06:17:54 +0000 (+0200) Subject: gvLayoutJobs: initialize also root graph if it isn't already X-Git-Tag: 5.0.1~31^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23c2388d7bc353265bebe96dd9792422a749027e;p=graphviz gvLayoutJobs: initialize also root graph if it isn't already The root graph info is needed by gvLayoutJobs when doing subgraph layout. This fixes a heap-buffer-overflow detected by ASan in the test_subgraph_layout test. --- diff --git a/lib/gvc/gvlayout.c b/lib/gvc/gvlayout.c index 00ae33a4d..a8cde85c0 100644 --- a/lib/gvc/gvlayout.c +++ b/lib/gvc/gvlayout.c @@ -58,8 +58,10 @@ int gvLayoutJobs(GVC_t * gvc, Agraph_t * g) agbindrec(g, "Agraphinfo_t", sizeof(Agraphinfo_t), true); GD_gvc(g) = gvc; - if (g != agroot(g)) - GD_gvc(agroot(g)) = gvc; + if (g != agroot(g)) { + agbindrec(agroot(g), "Agraphinfo_t", sizeof(Agraphinfo_t), true); + GD_gvc(agroot(g)) = gvc; + } if ((p = agget(g, "layout"))) { gvc->layout.engine = NULL;