circogen: layout: fix heap-buffer-overflow by storing dimension in root graph
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Mon, 18 Jul 2022 12:56:45 +0000 (14:56 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Mon, 25 Jul 2022 18:24:49 +0000 (20:24 +0200)
commitb2ea962f31e4c70fe94f256bf39236598824dd6a
treec804aa8fc35b35cb5f76f210ea12128480324b18
parent62f88c16e79ffdac6aaec150b9f5fdb6fd8c0db9
circogen: layout: fix heap-buffer-overflow by storing dimension in root graph

The layout allocates memory based on the dimension of the root graph,
but since the dimension was stored in the subgraph and the dimension
in the root graph defaulted to zero, too little memory was allocated.

An alternative solution would have been to use the dimension of the
subgraph, but this had other implications and the chosen solution is
the same as what the other two layout engines supporting the `dim`
attribute (neato and sfdp) use. Circo always uses two dimensions.
lib/circogen/circularinit.c