Skip to content

Commit 27af3ed

Browse files
committed
CheckStl: Safer use of AST
1 parent d13a8d6 commit 27af3ed

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

lib/checkstl.cpp

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,12 @@ void CheckStl::iterators()
140140
validIterator = true;
141141

142142
// Is iterator compared against different container?
143-
if (tok2->isComparisonOp() && container) {
143+
if (tok2->isComparisonOp() && container && tok2->astOperand1() && tok2->astOperand2()) {
144144
const Token *other = nullptr;
145145
if (tok2->astOperand1()->varId() == iteratorId)
146146
other = tok2->astOperand2()->tokAt(-3);
147147
else if (tok2->astOperand2()->varId() == iteratorId)
148148
other = tok2->astOperand1()->tokAt(-3);
149-
150149
if (Token::Match(other, "%name% . end|rend|cend|crend ( )") && other->varId() != container->declarationId())
151150
iteratorsError(tok2, container->name(), other->str());
152151
}

0 commit comments

Comments
 (0)