summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2025-05-31 08:23:46 +0000
committertb <>2025-05-31 08:23:46 +0000
commitc7aacb489daeb3adc420b15aa8be9c46f7af61d7 (patch)
tree3a716de9e4593d68281a86eb13af06e0e4478489 /src
parent4dd9a6dd5754c831a01167c4a8358aca64dc4059 (diff)
downloadopenbsd-c7aacb489daeb3adc420b15aa8be9c46f7af61d7.tar.gz
openbsd-c7aacb489daeb3adc420b15aa8be9c46f7af61d7.tar.bz2
openbsd-c7aacb489daeb3adc420b15aa8be9c46f7af61d7.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/test/test.c5
1 files changed, 3 insertions, 2 deletions
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 @@
1/* $OpenBSD: test.c,v 1.1 2025/05/21 08:57:13 joshua Exp $ */ 1/* $OpenBSD: test.c,v 1.2 2025/05/31 08:23:46 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2025 Joshua Sing <joshua@joshuasing.dev> 3 * Copyright (c) 2025 Joshua Sing <joshua@joshuasing.dev>
4 * 4 *
@@ -46,7 +46,8 @@ test_new(struct test *pt, const char *name)
46 err(1, "strdup"); 46 err(1, "strdup");
47 } 47 }
48 48
49 t->out = pt->out; 49 if (pt != NULL)
50 t->out = pt->out;
50 t->parent = pt; 51 t->parent = pt;
51 52
52 return t; 53 return t;