CheckFunctions::memsetZeroBytes: Add CHECK_WRONG_DATA to avoid crashes

This commit is contained in:
Daniel Marjamäki 2017-04-30 18:58:51 +02:00
parent 8a08cc0796
commit 9cdda53fb9
1 changed files with 4 additions and 1 deletions

View File

@ -308,7 +308,10 @@ void CheckFunctions::memsetZeroBytes()
const Scope * scope = symbolDatabase->functionScopes[i];
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
if (Token::Match(tok, "memset|wmemset (") && (numberOfArguments(tok)==3)) {
const Token* lastParamTok = getArguments(tok)[2];
const std::vector<const Token *> &arguments = getArguments(tok);
if (!CHECK_WRONG_DATA(arguments.size() == 3U))
continue;
const Token* lastParamTok = arguments[2];
if (lastParamTok->str() == "0")
memsetZeroBytesError(tok);
}