UninitVar: Fixed false positive 'data is allocated but not initialized' when there is assignment
This commit is contained in:
parent
0afdbc73da
commit
7fc07989a7
|
@ -493,7 +493,7 @@ private:
|
|||
for (it = checks.begin(); it != checks.end(); ++it) {
|
||||
UninitVar *c = dynamic_cast<UninitVar *>(*it);
|
||||
if (c && c->varId == tok.varId()) {
|
||||
if (c->var->isArray())
|
||||
if (c->var->isArray() || c->alloc)
|
||||
bailOutVar(checks, tok.varId());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1437,6 +1437,15 @@ private:
|
|||
" uintptr_t y = x + 10;\n" // <- not bad usage
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("void f() {\n"
|
||||
" z_stream strm;\n"
|
||||
" char* buf = malloc(10);\n"
|
||||
" strm.next_out = buf;\n"
|
||||
" deflate(&strm, Z_FINISH);\n"
|
||||
" memcpy(body, buf, 10);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// class / struct..
|
||||
|
|
Loading…
Reference in New Issue