From 23c2388d7bc353265bebe96dd9792422a749027e Mon Sep 17 00:00:00 2001 From: Magnus Jacobsson Date: Wed, 13 Jul 2022 08:17:54 +0200 Subject: [PATCH] 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. --- lib/gvc/gvlayout.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; -- 2.40.0