Remove unnecessary null check (#3215)

Spotted by coverity (as the condition in the `if` part `isArrayVar(tok)`
dereferences tok.
Tok can't be null here, because the condition in the `else if`on line
268 checks that there is a `%var%` following, and
`tok = Token::findmatch(tok->next(), "%var%");` simply gets this `%var%`
token.
This commit is contained in:
Ken-Patrick Lehrmann 2021-04-28 18:05:32 +02:00 committed by GitHub
parent d2184ac6a8
commit 9aa131a12e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -270,7 +270,7 @@ void CheckAutoVariables::autoVariables()
tok = Token::findmatch(tok->next(), "%var%");
if (isArrayVar(tok))
errorInvalidDeallocation(tok, nullptr);
else if (tok && tok->variable() && tok->variable()->isPointer()) {
else if (tok->variable() && tok->variable()->isPointer()) {
for (const ValueFlow::Value &v : tok->values()) {
if (!(v.isTokValue()))
continue;