Fix FP with embedded zeros (#4226)

* Partial fix for #11137 FN: invalidFunctionArgStr printf argument

* Typo

* Remove <strz>, suppressions

* Add suppresion, remove <strz>

* Add suppressions

* Fix FP with embedded zeros

* Merge
This commit is contained in:
chrchr-github 2022-06-21 13:33:45 +02:00 committed by GitHub
parent de2509f1ac
commit 0d4b4394bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -174,7 +174,7 @@ void CheckFunctions::invalidFunctionUsage()
const Token* strTok = varTok->getValueTokenMinStrSize(mSettings);
if (strTok) {
const int strSize = Token::getStrArraySize(strTok);
if (strSize > count)
if (strSize > count && strTok->str().find('\0') == std::string::npos)
invalidFunctionArgStrError(argtok, functionToken->str(), argnr);
}
}

View File

@ -729,6 +729,12 @@ private:
" strcat(dest, if_name);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("int f() {\n"
" const char c[3] = \"ab\\0\";\n"
" return strlen(c);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void mathfunctionCall_sqrt() {