Tokenizer: Fix crash in Token::previous() method ('this' is NULL)

This commit is contained in:
Daniel Marjamäki 2014-03-18 20:29:37 +01:00
parent 8492400e6f
commit ebb0c50aac
1 changed files with 4 additions and 4 deletions

View File

@ -9134,21 +9134,21 @@ void Tokenizer::simplifyAttribute()
if (Token::simpleMatch(tok->tokAt(2), "( pure )")) {
// type func(...) __attribute__((pure));
if (tok->next()->link()->next()->str() == ";")
if (tok->previous() && tok->previous()->link() && Token::Match(tok->previous()->link()->previous(), "%var% ("))
tok->previous()->link()->previous()->isAttributePure(true);
// type __attribute__((pure)) func() { }
else
else if (Token::Match(tok->next()->link(), ") %var% ("))
tok->next()->link()->next()->isAttributePure(true);
}
if (Token::simpleMatch(tok->tokAt(2), "( const )")) {
// type func(...) __attribute__((const));
if (tok->next()->link()->next()->str() == ";")
if (tok->previous() && tok->previous()->link() && Token::Match(tok->previous()->link()->previous(), "%var% ("))
tok->previous()->link()->previous()->isAttributeConst(true);
// type __attribute__((const)) func() { }
else
else if (Token::Match(tok->next()->link(), ") %var% ("))
tok->next()->link()->next()->isAttributeConst(true);
}