-
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
base: main
Are you sure you want to change the base?
Conversation
mExecuteCommand
is emptymExecuteCommand
is empty
This only fixes the crash when running an scratchpad analysis with a loaded projects including addons. It will now show an error instead. The execute function is not available in that context and it requires some refactoring. But I think that is something to look into in the context of https://trac.cppcheck.net/ticket/13976. |
This comment was marked as resolved.
This comment was marked as resolved.
988764d
to
e6a6e24
Compare
I moved the checks from the executor tests as the code being tested was not specific to those classes and actually lives in |
… shadowed a base member variable)
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
hmm.. ideally I would like to make it clear that it's a bug in cppcheck. The user should not start looking for some command callback options. but I don't have a very good suggestion..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well - it should never happen. It's kind of akin to "unreachable" code.
@@ -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 comment
The 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 comment
The 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.
No description provided.