diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index f4510bb55..03916bf74 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -137,6 +137,13 @@ int main(int ac, char *av[]) { int result; @CMAKE_TESTDRIVER_BEFORE_TESTMAIN@ + if (testToRun < 0 || testToRun >= NumTests) + { + printf( + "testToRun was modified by TestDriver code to an invalid value: %3d.\n", + testNum); + return -1; + } result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av); @CMAKE_TESTDRIVER_AFTER_TESTMAIN@ return result;