Skip to content

Commit

Permalink
Avoid crash if incorrect command line option is used
Browse files Browse the repository at this point in the history
Fix this:

./bpftrace -v
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid
Aborted (core dumped)
  • Loading branch information
caringi committed Apr 16, 2019
1 parent 0debfc1 commit aa24f29
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.cpp
Expand Up @@ -198,12 +198,12 @@ int main(int argc, char *argv[])
if (script.empty())
{
// Script file
file_name = std::string(argv[optind]);
if (file_name.empty())
if (argv[optind] == nullptr)
{
std::cerr << "USAGE: filename or -e 'program' required." << std::endl;
return 1;
}
file_name = std::string(argv[optind]);
err = driver.parse_file(file_name);
optind++;
}
Expand Down

0 comments on commit aa24f29

Please sign in to comment.