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 }
|
// goto the }
|
||||||
tok = tok->link();
|
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 (!Token::Match(tok, "} else {")) {
|
||||||
if (initif) {
|
if (initif) {
|
||||||
++number_of_if;
|
++number_of_if;
|
||||||
|
|
|
@ -1778,6 +1778,14 @@ private:
|
||||||
" return x;\n"
|
" return x;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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