This commit is contained in:
parent
49117f5aeb
commit
6eab3cb8bd
|
@ -439,7 +439,7 @@ static std::list<std::pair<const Token *, MathLib::bigint>> getUnsafeFunction(co
|
||||||
{
|
{
|
||||||
std::list<std::pair<const Token *, MathLib::bigint>> ret;
|
std::list<std::pair<const Token *, MathLib::bigint>> ret;
|
||||||
const Variable * const argvar = scope->function->getArgumentVar(argnr);
|
const Variable * const argvar = scope->function->getArgumentVar(argnr);
|
||||||
if (!argvar->isPointer() && !argvar->isReference())
|
if (!argvar->isArrayOrPointer() && !argvar->isReference())
|
||||||
return ret;
|
return ret;
|
||||||
for (const Token *tok2 = scope->bodyStart; tok2 != scope->bodyEnd; tok2 = tok2->next()) {
|
for (const Token *tok2 = scope->bodyStart; tok2 != scope->bodyEnd; tok2 = tok2->next()) {
|
||||||
if (Token::Match(tok2, ")|else {")) {
|
if (Token::Match(tok2, ")|else {")) {
|
||||||
|
|
|
@ -5058,6 +5058,18 @@ private:
|
||||||
" get_mac_address(macstrbuf);\n"
|
" get_mac_address(macstrbuf);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #9788
|
||||||
|
ctu("void f1(char *s) { s[2] = 'B'; }\n"
|
||||||
|
"void f2(char s[]) { s[2] = 'B'; }\n"
|
||||||
|
"void g() {\n"
|
||||||
|
" char str[2];\n"
|
||||||
|
" f1(str);\n"
|
||||||
|
" f2(str);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:1]: (error) Array index out of bounds; 's' buffer size is 2 and it is accessed at offset 2.\n"
|
||||||
|
"[test.cpp:6] -> [test.cpp:2]: (error) Array index out of bounds; 's' buffer size is 2 and it is accessed at offset 2.\n",
|
||||||
|
errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctu_variable() {
|
void ctu_variable() {
|
||||||
|
|
Loading…
Reference in New Issue