avoid crash when else condition doesn't have braces to link

This commit is contained in:
Greg Hewgill 2011-02-20 23:44:18 +13:00
parent 610d2efaea
commit 8c1d7ef316
1 changed files with 7 additions and 0 deletions

View File

@ -415,6 +415,13 @@ void CheckOther::checkSwitchCaseFallThrough()
{
tok2 = tok2->tokAt(2);
ifnest.pop();
if (tok2->link() == NULL)
{
std::ostringstream errmsg;
errmsg << "unmatched if in switch: " << tok2->linenr();
reportError(_tokenizer->tokens(), Severity::debug, "debug", errmsg.str());
break;
}
ifnest.push(std::make_pair(tok2->link(), justbreak));
justbreak = false;
}