UninitVar: Fixed false positive 'data is allocated but not initialized' when there is assignment

This commit is contained in:
Daniel Marjamäki 2013-11-23 10:24:29 +01:00
parent 0afdbc73da
commit 7fc07989a7
2 changed files with 10 additions and 1 deletions

View File

@ -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;
}

View File

@ -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..