From a226c3232ac39cfb896d926f7f876a75df3851f3 Mon Sep 17 00:00:00 2001 From: Oliver Sander <oliver.sander@tu-dresden.de> Date: Fri, 2 Aug 2024 19:20:12 +0200 Subject: [PATCH] cosserat-continuum.cc: Check whether argv[1] exists before using it --- src/cosserat-continuum.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc index 328f10fe..f29ef2dc 100644 --- a/src/cosserat-continuum.cc +++ b/src/cosserat-continuum.cc @@ -120,6 +120,11 @@ int main (int argc, char *argv[]) try std::cout << "MIXED_SPACE = 0" << std::endl; #endif } + + // Check for appropriate number of command line arguments + if (argc < 3) + DUNE_THROW(Exception, "Usage: ./cosserat-continuum <python path> <parameter file>"); + // Start Python interpreter Python::start(); Python::Reference main = Python::import("__main__"); @@ -137,9 +142,6 @@ int main (int argc, char *argv[]) try // parse data file ParameterTree parameterSet; - if (argc < 3) - DUNE_THROW(Exception, "Usage: ./cosserat-continuum <python path> <parameter file>"); - ParameterTreeParser::readINITree(argv[2], parameterSet); ParameterTreeParser::readOptions(argc, argv, parameterSet); -- GitLab