From 6fc8e914672f1f6ae9ec48da0dc9c128c25f0f80 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 14 Jan 2023 15:42:55 -0800 Subject: [PATCH] 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`. --- CHANGELOG.md | 1 + cmd/tools/ccomps.c | 1 + 2 files changed, 2 insertions(+) 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); -- 2.50.1