Fixed #2120 (False positive: array index out of bounds (unknown type in struct, sub function))
This commit is contained in:
parent
7b630cc581
commit
b55f6458a2
|
@ -1804,7 +1804,7 @@ bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &t
|
|||
_element_size = 0;
|
||||
_varname.clear();
|
||||
|
||||
if (!tok->isName())
|
||||
if (!tok->isName() || tok->str() == "return")
|
||||
return false;
|
||||
|
||||
while (tok && (tok->str() == "static" ||
|
||||
|
|
|
@ -180,6 +180,7 @@ private:
|
|||
|
||||
TEST_CASE(executionPaths1);
|
||||
TEST_CASE(executionPaths2);
|
||||
TEST_CASE(executionPaths3); // no FP for function parameter
|
||||
|
||||
TEST_CASE(cmdLineArgs1);
|
||||
|
||||
|
@ -2514,6 +2515,20 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void executionPaths3()
|
||||
{
|
||||
epcheck("void f(char *VLtext)\n"
|
||||
"{\n"
|
||||
" if ( x ) {\n"
|
||||
" return VLtext[0];\n"
|
||||
" } else {\n"
|
||||
" int wordlen = ab();\n"
|
||||
" VLtext[wordlen] = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void cmdLineArgs1()
|
||||
{
|
||||
check("int main(int argc, char* argv[])\n"
|
||||
|
|
Loading…
Reference in New Issue