Calling std::exit() in the middle of a C++ program subverts stack unwinding and can introduce subtle bugs.

This commit is contained in:
Dmitry-Me 2014-06-05 11:28:04 +04:00
parent 0a0f1072c0
commit 738d05b442
1 changed files with 8 additions and 3 deletions

View File

@ -81,10 +81,12 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
std::cout << ErrorLogger::ErrorMessage::getXMLFooter(settings._xml_version) << std::endl;
}
if (parser.ExitAfterPrinting())
std::exit(EXIT_SUCCESS);
if (parser.ExitAfterPrinting()) {
settings.terminate();
return true;
}
} else {
std::exit(EXIT_FAILURE);
return false;
}
// Check that all include paths exist
@ -173,6 +175,9 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
if (!parseFromArgs(&cppCheck, argc, argv)) {
return EXIT_FAILURE;
}
if (settings.terminated()) {
return EXIT_SUCCESS;
}
if (cppCheck.settings().exceptionHandling) {
return check_wrapper(cppCheck, argc, argv);