From caeb660774869ad8f1c5b856f8a2207830603a9d Mon Sep 17 00:00:00 2001 From: Robert Chisholm Date: Wed, 8 Apr 2020 16:50:58 +0100 Subject: [PATCH] Fixes #224 --- src/flamegpu/sim/Simulation.cu | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/flamegpu/sim/Simulation.cu b/src/flamegpu/sim/Simulation.cu index 6154e5da3..113e85495 100644 --- a/src/flamegpu/sim/Simulation.cu +++ b/src/flamegpu/sim/Simulation.cu @@ -84,16 +84,28 @@ int Simulation::checkArgs(int argc, const char** argv) { std::transform(arg.begin(), arg.end(), arg.begin(), [](unsigned char c) { return std::use_facet< std::ctype>(std::locale()).tolower(c); }); // -in , Specifies the input state file if (arg.compare("--in") == 0 || arg.compare("-i") == 0) { + if (i + 1 >= argc) { + fprintf(stderr, "%s requires a trailing argument\n", arg.c_str()); + return false; + } config.xml_input_file = std::string(argv[++i]); continue; } // -steps , The number of steps to be executed if (arg.compare("--steps") == 0 || arg.compare("-s") == 0) { + if (i + 1 >= argc) { + fprintf(stderr, "%s requires a trailing argument\n", arg.c_str()); + return false; + } config.steps = static_cast(strtoul(argv[++i], nullptr, 0)); continue; } // -random , Uses the specified random seed, defaults to clock if (arg.compare("--random") == 0 || arg.compare("-r") == 0) { + if (i + 1 >= argc) { + fprintf(stderr, "%s requires a trailing argument\n", arg.c_str()); + return false; + } // Reinitialise RandomManager state config.random_seed = static_cast(strtoul(argv[++i], nullptr, 0)); continue;