Memory leak in virtual_node when dot lays out clusters
Created by: pixelglow
The virtual_node
allocation in fastgr.c:240 leaks when dot lays out clusters, according to the Leaks instrument on Mac developer tools.
Near as I can figure, in dot_mincross
, the virtual node is allocated in init_mincross
mincross.c:337, then in merge2
mincross.c:344, the virtual node is dropped without deallocation.
Here's the stack trace for the allocation according to Leaks:
malloc_zone_malloc
malloc
gmalloc
zmalloc
virtual_node
build_skeleton
class2
dot_mincross
dotLayout
dot_layout
gvLayoutJobs
gvLayout
Here's the stack trace for dropping that I constructed by tracing in a debugger:
mincross.c:945
merge_components (mincross.c:957)
merge2 (mincross.c:344)
dot_mincross
In particular, mincross.c line 945 sets GD_nlist(g)
to some value, which overwrites the previously allocated virtual node without deallocating it. It doesn't look like the virtual node is saved anywhere else, hence the memory leak.
I'm not familiar enough with the subtleties of dot layout to fix this on my own. I would suggest inserting a virtual node cleanup at mincross.c:343 if the virtual nodes are indeed not required past that point.