From c7aacb489daeb3adc420b15aa8be9c46f7af61d7 Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 31 May 2025 08:23:46 +0000 Subject: test.c: avoid NULL-dereference test_init() calls test_new(NULL, NULL), which leads to a segfault. llvm 16 optimizes this away with -O2, however gcc 4.2.1 on sparc64 doesn't. Fix this by only inheriting the out FILE from the parent if the latter is non-NULL. --- src/regress/lib/libcrypto/test/test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/regress/lib/libcrypto/test') diff --git a/src/regress/lib/libcrypto/test/test.c b/src/regress/lib/libcrypto/test/test.c index b48711919d..ca3149217a 100644 --- a/src/regress/lib/libcrypto/test/test.c +++ b/src/regress/lib/libcrypto/test/test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test.c,v 1.1 2025/05/21 08:57:13 joshua Exp $ */ +/* $OpenBSD: test.c,v 1.2 2025/05/31 08:23:46 tb Exp $ */ /* * Copyright (c) 2025 Joshua Sing * @@ -46,7 +46,8 @@ test_new(struct test *pt, const char *name) err(1, "strdup"); } - t->out = pt->out; + if (pt != NULL) + t->out = pt->out; t->parent = pt; return t; -- cgit v1.2.3-55-g6feb