]> granicus.if.org Git - graphviz/commitdiff
gvLayoutJobs: initialize also root graph if it isn't already
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Wed, 13 Jul 2022 06:17:54 +0000 (08:17 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Mon, 25 Jul 2022 18:24:49 +0000 (20:24 +0200)
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.

lib/gvc/gvlayout.c

index 00ae33a4d2a68ca2fc3e03deea894e2341d099f4..a8cde85c072e495a7b07cdf30494b16fc9908dbc 100644 (file)
@@ -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;