Fixed #4927 (Segfault in CheckOther::checkCommaSeparatedReturn() on invalid code)
This commit is contained in:
parent
43f0be06fa
commit
40fa474a5b
|
@ -1886,7 +1886,7 @@ void CheckOther::checkCommaSeparatedReturn()
|
|||
for (const Token *tok = _tokenizer->tokens(); tok ; tok = tok->next()) {
|
||||
if (Token::Match(tok ,"return")) {
|
||||
|
||||
while (tok->str() != ";") {
|
||||
while (tok && tok->str() != ";") {
|
||||
|
||||
if (tok->str() == "(")
|
||||
tok=tok->link();
|
||||
|
@ -1911,6 +1911,9 @@ void CheckOther::checkCommaSeparatedReturn()
|
|||
|
||||
tok=tok->next();
|
||||
}
|
||||
// bailout: missing semicolon (invalid code / bad tokenizer)
|
||||
if (!tok)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6310,6 +6310,12 @@ private:
|
|||
" return a<int,\nint>::b;\n"
|
||||
"}", NULL, false, false, false, false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ticket #4927 Segfault in CheckOther::checkCommaSeparatedReturn() on invalid code
|
||||
check("int main() {\n"
|
||||
" return 0\n"
|
||||
"}", NULL, false, false, false, false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue