Fix uninitdata regression (#5179)
This commit is contained in:
parent
16198a47fa
commit
4eebf2e733
|
@ -1253,7 +1253,7 @@ const Token* CheckUninitVar::isVariableUsage(bool cpp, const Token *vartok, cons
|
||||||
const Token* deref = derefValue->astOperand1();
|
const Token* deref = derefValue->astOperand1();
|
||||||
while (deref && deref->isCast())
|
while (deref && deref->isCast())
|
||||||
deref = deref->astOperand1();
|
deref = deref->astOperand1();
|
||||||
if (deref == vartok)
|
if (deref == vartok || Token::simpleMatch(deref, "+"))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (alloc != NO_ALLOC && astIsRhs(valueExpr))
|
if (alloc != NO_ALLOC && astIsRhs(valueExpr))
|
||||||
|
|
|
@ -2080,6 +2080,13 @@ private:
|
||||||
" return p;\n"
|
" return p;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("void f(int n) {\n"
|
||||||
|
" int* p = (int*)malloc(n * sizeof(int));\n"
|
||||||
|
" for (int i = 0; i < n; ++i)\n"
|
||||||
|
" *(p + i) = 0;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// class / struct..
|
// class / struct..
|
||||||
|
|
Loading…
Reference in New Issue