Skip to content

Commit c501ff3

Browse files
committed
Fix
1 parent b8fab85 commit c501ff3

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

lib/checkuninitvar.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -784,15 +784,14 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const Variable& var
784784
// standard or enum type: check if new initializes the allocated memory
785785
if (var.typeStartToken()->isStandardType() || var.typeStartToken()->isEnumType()) {
786786
// scalar new with initialization
787-
if (Token::Match(tok->next(), "= new %type% ("))
788-
return true;
789-
790787
// array new
791788
if (Token::Match(tok->next(), "= new ::|%type")) {
792789
const Token* initTok = tok->tokAt(4);
793-
while (Token::Match(initTok, "::|%type"))
790+
while (Token::Match(initTok, "::|%type%"))
794791
initTok = initTok->next();
795-
if (Token::Match(initTok->link(), "] [({]"))
792+
if (Token::simpleMatch(initTok, "["))
793+
initTok = initTok->link()->next();
794+
if (Token::Match(initTok, "[({]"))
796795
return true;
797796
}
798797
}

0 commit comments

Comments
 (0)