Fixed #2096 (False positive: buffer overrun (extern array))

This commit is contained in:
Daniel Marjamäki 2010-10-13 20:57:59 +02:00
parent 267d1f273e
commit b6c995ea47
2 changed files with 10 additions and 1 deletions

View File

@ -1794,7 +1794,9 @@ bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &t
if (!tok->isName()) if (!tok->isName())
return false; return false;
while (tok && (tok->str() == "static" || tok->str() == "const")) while (tok && (tok->str() == "static" ||
tok->str() == "const" ||
tok->str() == "extern"))
tok = tok->next(); tok = tok->next();
int ivar = 0; int ivar = 0;

View File

@ -1700,6 +1700,13 @@ private:
" strcpy(x, \"12\");\n" " strcpy(x, \"12\");\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("extern char a[10];\n"
"void f() {\n"
" char b[25] = {0};\n"
" std::memcpy(b, a, sizeof(a));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
void sprintf1() void sprintf1()