Fixed #9112 (false positive: (error) Array index out of bounds; buffer 'x' is accessed at offset n.)
This commit is contained in:
parent
b3a46e72dc
commit
6da42a3d63
|
@ -749,7 +749,7 @@ bool CheckBufferOverrun::isCtuUnsafeBufferUsage(const Check *check, const Token
|
||||||
const CheckBufferOverrun *c = dynamic_cast<const CheckBufferOverrun *>(check);
|
const CheckBufferOverrun *c = dynamic_cast<const CheckBufferOverrun *>(check);
|
||||||
if (!c)
|
if (!c)
|
||||||
return false;
|
return false;
|
||||||
if (!argtok->valueType())
|
if (!argtok->valueType() || argtok->valueType()->typeSize(*c->mSettings) == 0)
|
||||||
return false;
|
return false;
|
||||||
const Token *indexTok = nullptr;
|
const Token *indexTok = nullptr;
|
||||||
if (type == 1 && Token::Match(argtok, "%name% [") && argtok->astParent() == argtok->next() && !Token::simpleMatch(argtok->linkAt(1), "] ["))
|
if (type == 1 && Token::Match(argtok, "%name% [") && argtok->astParent() == argtok->next() && !Token::simpleMatch(argtok->linkAt(1), "] ["))
|
||||||
|
|
|
@ -4176,6 +4176,19 @@ private:
|
||||||
" foo(p+1);\n"
|
" foo(p+1);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #9112
|
||||||
|
ctu("static void get_mac_address(const u8 *strbuf)\n"
|
||||||
|
"{\n"
|
||||||
|
" (strbuf[2]);\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"static void program_mac_address(u32 mem_base)\n"
|
||||||
|
"{\n"
|
||||||
|
" u8 macstrbuf[17] = { 0 };\n"
|
||||||
|
" get_mac_address(macstrbuf);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctu_variable() {
|
void ctu_variable() {
|
||||||
|
|
Loading…
Reference in New Issue