From c987a1561090032e93c458519091872ce424d182 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Tue, 6 Feb 2024 16:34:47 +0100 Subject: [PATCH] Fix segfault for wrongly specified test on commandline. (#21) 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);