-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fixed #13982 - cppcheck.cpp: do not crash if mExecuteCommand
is empty
#7647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
959c749
81b3ae9
e118e4c
50c046b
f06b188
7a98a7f
e63b3cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -432,6 +432,9 @@ static std::vector<picojson::value> executeAddon(const AddonInfo &addonInfo, | |
const std::string &premiumArgs, | ||
const CppCheck::ExecuteCmdFn &executeCommand) | ||
{ | ||
if (!executeCommand) | ||
throw InternalError(nullptr, "Failed to execute addon - no command callback provided"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about writing it more detailed.. |
||
|
||
std::string pythonExe; | ||
|
||
if (!addonInfo.executable.empty()) | ||
|
@@ -441,7 +444,7 @@ static std::vector<picojson::value> executeAddon(const AddonInfo &addonInfo, | |
else if (!defaultPythonExe.empty()) | ||
pythonExe = cmdFileName(defaultPythonExe); | ||
else { | ||
// store in static variable so we only look this up once | ||
// store in static variable so we only look this up once - TODO: do not cache globally | ||
static const std::string detectedPythonExe = detectPython(executeCommand); | ||
if (detectedPythonExe.empty()) | ||
throw InternalError(nullptr, "Failed to auto detect python"); | ||
|
@@ -686,6 +689,11 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file, int fileIndex) | |
mErrorLogger.reportOut(exe + " " + args2, Color::Reset); | ||
} | ||
|
||
if (!mExecuteCommand) { | ||
std::cerr << "Failed to execute '" << exe << " " << args2 << " " << redirect2 << "' - (no command callback provided)" << std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why isn't this reported to the errorlogger. GUI does not capture stderr. And plugins will probably not write this. So the user will have no clue why it does not work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because that was never properly implemented for this. It's the same in another cases and there's TODOs in the code. Will check if we have tickets about this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what I am missing. What is stopping you from calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It just was never implemented that way back when this functionality was introduced. That is outside of the scope of this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we write this code instead:
It still compiles. I don't ask that you change other std::cerr/std::cout statements throughout the code, those should be fixed but I agree that is out of scope. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will file tickets and address this in a follow-up. |
||
return 0; // TODO: report as failure? | ||
} | ||
|
||
std::string output2; | ||
const int exitcode = mExecuteCommand(exe,split(args2),redirect2,output2); | ||
if (mSettings.debugClangOutput) { | ||
|
@@ -1954,6 +1962,11 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings) | |
} | ||
#endif | ||
|
||
if (!mExecuteCommand) { | ||
std::cerr << "Failed to execute '" << exe << "' (no command callback provided)" << std::endl; | ||
return; | ||
} | ||
|
||
Comment on lines
+1965
to
+1969
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reporting a proper error is already tracked in https://trac.cppcheck.net/ticket/13827. |
||
// TODO: log this call | ||
// TODO: get rid of hard-coded checks | ||
const std::string args = "-quiet -checks=*,-clang-analyzer-*,-llvm* \"" + fileSettings.filename() + "\" -- " + allIncludes + allDefines; | ||
|
Uh oh!
There was an error while loading. Please reload this page.