From f4677c89d6a4a97e79894f015272a09b79735fa0 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 16 Mar 2026 15:49:18 +0100 Subject: [PATCH] Fix null pointer dereference in the child if fdopen fails Signed-off-by: Gilles Peskine --- tests/src/fork_helpers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/src/fork_helpers.c b/tests/src/fork_helpers.c index 1c05838c6..dc4e4fea3 100644 --- a/tests/src/fork_helpers.c +++ b/tests/src/fork_helpers.c @@ -57,7 +57,11 @@ static void run_child( FILE *file = fdopen(write_fd, "a"); size_t length = 0; - TEST_ASSERT_ERRNO(file != NULL); + if (file == NULL) { + /* There's no way we can report anything other than the exit code. + * So we might as well quit without even running the child callback. */ + goto write_done; + } child_callback(param, buf, size, &length);