Skip to content
Snippets Groups Projects
Commit 82e1f598 authored by nkindlon's avatar nkindlon
Browse files

Corrected intersect showHelp segfault.

parent c2fb3e5c
No related branches found
No related tags found
No related merge requests found
...@@ -24,12 +24,14 @@ int intersect_main(int argc, char* argv[]) { ...@@ -24,12 +24,14 @@ int intersect_main(int argc, char* argv[]) {
Context *context = new Context(); Context *context = new Context();
context->parseCmdArgs(argc, argv, 1); context->parseCmdArgs(argc, argv, 1);
if (!context->isValidState()) { if (context->getShowHelp() || !context->isValidState()) {
fprintf(stderr, "%s\n", context->getErrorMsg().c_str()); if (!context->getErrorMsg().empty()) {
cerr << context->getErrorMsg() << endl;
}
intersect_help(); intersect_help();
delete context;
return 0; return 0;
} }
FileIntersect *fileIntersect = new FileIntersect(context); FileIntersect *fileIntersect = new FileIntersect(context);
bool retVal = fileIntersect->intersectFiles(); bool retVal = fileIntersect->intersectFiles();
......
...@@ -94,6 +94,10 @@ void Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { ...@@ -94,6 +94,10 @@ void Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
_argc = argc; _argc = argc;
_argv = argv; _argv = argv;
_skipFirstArgs = skipFirstArgs; _skipFirstArgs = skipFirstArgs;
if (argc < 2) {
setShowHelp(true);
return;
}
_argsProcessed.resize(argc - skipFirstArgs, false); _argsProcessed.resize(argc - skipFirstArgs, false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment