Fixed #3415 (Segmentation fault in new check for uninitialized variables)
This commit is contained in:
parent
00d6a0e877
commit
b3c35d4b32
|
@ -1092,6 +1092,10 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const unsigned int
|
|||
// goto the }
|
||||
tok = tok->link();
|
||||
|
||||
// TODO: Make sure "if" blocks are surrounded by {} properly (#3415)
|
||||
if (!tok)
|
||||
return true; // bail out
|
||||
|
||||
if (!Token::Match(tok, "} else {")) {
|
||||
if (initif) {
|
||||
++number_of_if;
|
||||
|
|
|
@ -1778,6 +1778,14 @@ private:
|
|||
" return x;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// strange code.. don't crash (#3415)
|
||||
checkUninitVar2("void foo() {\n"
|
||||
" int i;\n"
|
||||
" ({ if (0); });\n"
|
||||
" for_each(i) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue