Moved CheckString::sprintfOverlappingData from runSimplifiedChecks to runChecks

This commit is contained in:
Daniel Marjamäki 2019-02-25 09:23:03 +01:00
parent 4218698fb1
commit f1146e398a
2 changed files with 12 additions and 3 deletions

View File

@ -428,10 +428,19 @@ void CheckString::sprintfOverlappingData()
const int formatString = Token::simpleMatch(tok, "sprintf") ? 1 : 2;
for (unsigned int argnr = formatString + 1; argnr < args.size(); ++argnr) {
const Token *dest = args[0];
if (dest->isCast())
dest = dest->astOperand2() ? dest->astOperand2() : dest->astOperand1();
const Token *arg = args[argnr];
if (!arg->valueType() || arg->valueType()->pointer != 1)
continue;
if (arg->isCast())
arg = arg->astOperand2() ? arg->astOperand2() : arg->astOperand1();
const bool same = isSameExpression(mTokenizer->isCPP(),
false,
args[0],
args[argnr],
dest,
arg,
mSettings->library,
true,
false);

View File

@ -59,6 +59,7 @@ public:
checkString.stringLiteralWrite();
checkString.overlappingStrcmp();
checkString.checkIncorrectStringCompare();
checkString.sprintfOverlappingData();
}
/** @brief Run checks against the simplified token list */
@ -67,7 +68,6 @@ public:
// Checks
checkString.checkAlwaysTrueOrFalseStringCompare();
checkString.sprintfOverlappingData();
}
/** @brief undefined behaviour, writing string literal */