Fixed #5166 (segmentation fault (invalid code) in lib/checkother.cpp:329 ( void * f { } void b ( ) { * f } ))

This commit is contained in:
Alexander Mai 2014-02-27 18:24:51 +01:00 committed by Daniel Marjamäki
parent 361a99f1af
commit 50a184c3e9
2 changed files with 5 additions and 1 deletions

View File

@ -364,7 +364,7 @@ void CheckOther::clarifyStatement()
const std::size_t functions = symbolDatabase->functionScopes.size();
for (std::size_t i = 0; i < functions; ++i) {
const Scope * scope = symbolDatabase->functionScopes[i];
for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
for (const Token* tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {
if (Token::Match(tok, "* %var%")) {
const Token *tok2=tok->previous();

View File

@ -4250,6 +4250,10 @@ private:
" bar(**c++);\n"
"}");
ASSERT_EQUALS("", errout.str());
// #5166 segmentation fault (invalid code) in lib/checkother.cpp:329 ( void * f { } void b ( ) { * f } )
check("void * f { } void b ( ) { * f }");
ASSERT_EQUALS("", errout.str());
}
// clarify conditions with = and comparison