From 8c1d7ef3161806294181c530c889f4d0f5d61b0a Mon Sep 17 00:00:00 2001 From: Greg Hewgill Date: Sun, 20 Feb 2011 23:44:18 +1300 Subject: [PATCH] avoid crash when else condition doesn't have braces to link --- lib/checkother.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index e3135dd71..93480de5e 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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; }