diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index dae17d67f..7c7914e03 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -663,7 +663,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector 0 && Token::Match(tok, "strcpy|strcat ( %varid% , %var% )", declarationId)) || (declarationId == 0 && Token::Match(tok, ("strcpy|strcat ( " + varnames + " , %var% )").c_str()))) { - const Variable *var = tok->tokAt(4)->variable(); + const Variable *var = tok->tokAt(varcount + 4)->variable(); if (var && var->isArray() && var->dimensions().size() == 1) { const std::size_t len = (std::size_t)var->dimension(0); if (len > (unsigned int)total_size) { diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index d0e82d198..eb51d0afd 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1348,10 +1348,8 @@ bool CheckClass::hasAllocation(const Function *func, const Scope* scope) const // Check for assignment to the deleted pointer (only if its a member of the class) if (var && isMemberVar(scope, var)) { for (const Token *tok1 = var->next(); tok1 && (tok1 != last); tok1 = tok1->next()) { - if (Token::Match(tok1, "%var% =")) { - if (tok1->str() == var->str()) - return true; - } + if (Token::Match(tok1, "%varid% =", var->varId())) + return true; } } }