dot: multiple graphs to file output causes a segfault
Steps to reproduce
With input file yoda.gvz containing:
digraph {
fear -> anger;
}
digraph {
anger -> hate;
}
run dot -Tps yoda.gvz -o yoda.ps
Expected Behaviour
Expect to get a 2-page postscript file, with the first containing the fear->anger graph, second containing anger->hate.
Actual Behaviour
dot segfaults, on my machine the message is [1] 1168930 segmentation fault (core dumped) dot -Tps yoda.gvz -o yoda.ps
OS Version
Linux, Ubuntu 20.04.1 LTS
Graphviz Version
2.38.0 (20140413.2041) - works as expected, in an Ubuntu 16.04 Docker container
2.43.0 (0) - fails
2.44.2~dev.20200930.1503 (20200930.1503) - built from 4747e3ff fails
Additional info
The segfault is due to the output file being closed after the first graph is written to it. I think the offending change is 806b8a2f - have attached a patch, but would be happy to make a MR if that is easier to deal with.
Edited by Ian Rees