From 876d24a475998111905837769e1532e5111ac4d6 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Tue, 6 Feb 2024 16:22:12 +0100 Subject: [PATCH] Fix segfault for wrongly specified test on commandline. If explicitly specified test does not exist, dieharder segfaults, for example dieharder -d 42 dieharder -d 5000 --- dieharder/run_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dieharder/run_test.c b/dieharder/run_test.c index b6ec195..810427b 100644 --- a/dieharder/run_test.c +++ b/dieharder/run_test.c @@ -28,7 +28,7 @@ void run_test() } } } - if(dtest_num >= 0){ + if(dtest_num >= 0 && dtest_num < MAXTESTS && dh_test_types[dtest_num]){ execute_test(dtest_num); } else { fprintf(stderr,"Error: dtest_num = %d. No test found.\n",dtest_num);