Fix crash in isSameExpression (#2748)

This commit is contained in:
Paul Fultz II 2020-08-22 00:05:21 -05:00 committed by GitHub
parent 33fb0e782e
commit becdf20310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -795,6 +795,8 @@ bool isSameExpression(bool cpp, bool macro, const Token *tok1, const Token *tok2
const Token *lhs = tok1->previous();
while (Token::Match(lhs, "(|.|["))
lhs = lhs->astOperand1();
if (!lhs)
return false;
const bool lhsIsConst = (lhs->variable() && lhs->variable()->isConst()) ||
(lhs->valueType() && lhs->valueType()->constness > 0) ||
(Token::Match(lhs, "%var% . %name% (") && library.isFunctionConst(lhs->tokAt(2)));