Fixed #3708 (False positive: uninitialized variable (allocation, unknown nonpointer type))
This commit is contained in:
parent
8a7b141246
commit
fc7f78244e
|
@ -91,8 +91,13 @@ private:
|
|||
std::list<ExecutionPath *>::const_iterator it;
|
||||
for (it = checks.begin(); it != checks.end(); ++it) {
|
||||
UninitVar *c = dynamic_cast<UninitVar *>(*it);
|
||||
if (c && c->varId == varid)
|
||||
if (c && c->varId == varid) {
|
||||
if (c->pointer)
|
||||
c->alloc = true;
|
||||
else
|
||||
bailOutVar(checks, varid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1300,6 +1300,13 @@ private:
|
|||
" char c = *s;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Data is allocated but not initialized: s\n", errout.str());
|
||||
|
||||
// #3708 - false positive when using ptr typedef
|
||||
checkUninitVar("void f() {\n"
|
||||
" uintptr_t x = malloc(100);\n"
|
||||
" uintptr_t y = x + 10;\n" // <- not bad usage
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// class / struct..
|
||||
|
|
Loading…
Reference in New Issue