From 82e1f598e26225781065186fd3bc127dc87e13cc Mon Sep 17 00:00:00 2001 From: nkindlon <nek3d@virginia.edu> Date: Wed, 11 Sep 2013 15:03:11 -0400 Subject: [PATCH] Corrected intersect showHelp segfault. --- src/intersectFile/intersectMain.cpp | 8 +++++--- src/utils/Contexts/Context.cpp | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/intersectFile/intersectMain.cpp b/src/intersectFile/intersectMain.cpp index 030d33a8..9fcb8a1b 100644 --- a/src/intersectFile/intersectMain.cpp +++ b/src/intersectFile/intersectMain.cpp @@ -24,12 +24,14 @@ int intersect_main(int argc, char* argv[]) { Context *context = new Context(); context->parseCmdArgs(argc, argv, 1); - if (!context->isValidState()) { - fprintf(stderr, "%s\n", context->getErrorMsg().c_str()); + if (context->getShowHelp() || !context->isValidState()) { + if (!context->getErrorMsg().empty()) { + cerr << context->getErrorMsg() << endl; + } intersect_help(); + delete context; return 0; } - FileIntersect *fileIntersect = new FileIntersect(context); bool retVal = fileIntersect->intersectFiles(); diff --git a/src/utils/Contexts/Context.cpp b/src/utils/Contexts/Context.cpp index fc24bb06..97143c22 100644 --- a/src/utils/Contexts/Context.cpp +++ b/src/utils/Contexts/Context.cpp @@ -94,6 +94,10 @@ void Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { _argc = argc; _argv = argv; _skipFirstArgs = skipFirstArgs; + if (argc < 2) { + setShowHelp(true); + return; + } _argsProcessed.resize(argc - skipFirstArgs, false); -- GitLab