From: Matthew Fernandez Date: Sat, 14 Jan 2023 23:42:55 +0000 (-0800) Subject: ccomps gwrite: fix crash when failing to open files X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6fc8e914672f1f6ae9ec48da0dc9c128c25f0f80;p=graphviz ccomps gwrite: fix crash when failing to open files This code looks as if it and the similar code in bcomps.c were copy-pasted from the same common source. Except the bcomps.c version remembered to exit when failing to open the output file, whereas the ccomps.c code would go on to crash when using the null `outf`. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index db129db99..a1a7b5eb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Compatibility with `/bin/sh` has been restored in the Autotools build system. This was a regression in Graphviz 7.0.6. This restores the ability to compile on NetBSD which was fixed in 7.0.4 but regressed in 7.0.6. #2340 +- `ccomps` no longer crashes when failing to open files. ## [7.0.6] – 2023-01-06 diff --git a/cmd/tools/ccomps.c b/cmd/tools/ccomps.c index b508afe15..e7ed8b3d9 100644 --- a/cmd/tools/ccomps.c +++ b/cmd/tools/ccomps.c @@ -325,6 +325,7 @@ static void gwrite(Agraph_t * g) if (!outf) { fprintf(stderr, "Could not open %s for writing\n", name); perror("ccomps"); + graphviz_exit(EXIT_FAILURE); } agwrite(g, outf); fclose(outf);