Skip to content

Commit

Permalink
Fix segmentation fault if file name is missing after arraylist command.
Browse files Browse the repository at this point in the history
  • Loading branch information
blattms committed Nov 9, 2023
1 parent af4b985 commit 796a641
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test_util/arraylist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ using EclEntry = Opm::EclIO::EclFile::EclEntry;

static void printHelp() {

std::cout << "\nList all arrays found in an EclFile specified on the command line. \n\n"
<< "\nThe program have one option which will only work on unified restart files:\n\n"
std::cout << "Usage: arraylist [OPTIONS] ECL_FILE_NAME"<<std::endl
<< "\nList all arrays found in an EclFile specified on the command line. \n\n"
<< "\nThe program has one option which will only work on unified restart files:\n\n"
<< "-h Print help and exit.\n"
<< "-r List array for a specific report time step number. Option only valid for a unified restart file. \n\n";
}
Expand Down Expand Up @@ -110,6 +111,14 @@ int main(int argc, char **argv) {

int argOffset = optind;

if(argOffset >= argc)
{
std::cerr<<"Eclipse file name is missing. Please provide it "
<<"as the last argument."<<std::endl<<std::endl;
printHelp();
return EXIT_FAILURE;
}

std::filesystem::path filename(argv[argOffset]);

std::string ext = filename.extension().string();
Expand Down

0 comments on commit 796a641

Please sign in to comment.