Skip to content

Commit e7bb43f

Browse files
committed
Cache and reuse token pointer
1 parent 180d738 commit e7bb43f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/checkbufferoverrun.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,10 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
926926
if (isWarningEnabled && num >= total_size && _settings->inconclusive) {
927927
const Token *tok2 = tok->next()->link()->next();
928928
for (; tok2; tok2 = tok2->next()) {
929-
if (tok2->varId() == tok->tokAt(2)->varId()) {
930-
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId())) {
931-
terminateStrncpyError(tok, tok->strAt(2));
929+
const Token* tok3 = tok->tokAt(2);
930+
if (tok2->varId() == tok3->varId()) {
931+
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok3->varId())) {
932+
terminateStrncpyError(tok, tok3->str());
932933
}
933934

934935
break;

0 commit comments

Comments
 (0)