library.cpp: WarnInfo: Fix crash (#1697)
If no 'alternatives' argument was specified and the `<warn/>` element did not contain any text Cppcheck crashed because of a null pointer access. If there is no 'reason' and no 'alternatives argument and also no text loadFunction() returns with an error.
This commit is contained in:
parent
11daabc1a8
commit
c8a7a4c653
|
@ -723,8 +723,13 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
|
|||
else
|
||||
wi.message += ", ";
|
||||
}
|
||||
} else {
|
||||
const char * const message = functionnode->GetText();
|
||||
if (!message) {
|
||||
return Error(MISSING_ATTRIBUTE, "\"reason\" and \"alternatives\" or some text.");
|
||||
} else
|
||||
wi.message = functionnode->GetText();
|
||||
wi.message = message;
|
||||
}
|
||||
|
||||
functionwarn[name] = wi;
|
||||
} else
|
||||
|
|
Loading…
Reference in New Issue