Fix false positive: Invalid string argument with array (#1439)
This commit is contained in:
parent
40cb9cb1bc
commit
402d0c565f
|
@ -130,7 +130,7 @@ void CheckFunctions::invalidFunctionUsage()
|
|||
if (Token::Match(argtok, "& %var% !![") && argtok->next() && argtok->next()->valueType()) {
|
||||
const ValueType * valueType = argtok->next()->valueType();
|
||||
const Variable * variable = argtok->next()->variable();
|
||||
if (valueType->type == ValueType::Type::CHAR && !variable->isGlobal() &&
|
||||
if (valueType->type == ValueType::Type::CHAR && !variable->isArray() && !variable->isGlobal() &&
|
||||
(!argtok->next()->hasKnownValue() || argtok->next()->getValue(0) == nullptr)) {
|
||||
invalidFunctionArgStrError(argtok, functionToken->str(), argnr);
|
||||
}
|
||||
|
|
|
@ -537,6 +537,12 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("size_t f() {\n"
|
||||
" char ca[] = \"asdf\";\n"
|
||||
" return strlen((char*) &ca);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #5225
|
||||
check("int main(void)\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue