uninitialized data: minor fix to handle 'new char [' better

This commit is contained in:
Daniel Marjamäki 2009-11-07 14:54:12 +01:00
parent 45406f5367
commit d88c236efe
2 changed files with 9 additions and 1 deletions

View File

@ -1422,7 +1422,9 @@ void CheckOther::uninitvar()
continue;
// goto ')'
tok = tok->tokAt(4)->link();
tok = tok->tokAt(4);
if (tok->str() == "(")
tok = tok->link();
if (!tok)
break;

View File

@ -1145,6 +1145,12 @@ private:
"};\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Data is allocated but not initialized: s\n", errout.str());
checkUninitVar("void f()\n"
"{\n"
" char *s1 = new char[10];\n"
" char *s2 = new char[strlen(s1)];\n"
"};\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Data is allocated but not initialized: s1\n", errout.str());
}