Skip to content

Commit 834570e

Browse files
Update checkautovariables.cpp
1 parent 8bc093c commit 834570e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/checkautovariables.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,11 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token
614614
}
615615
}
616616
}
617-
const bool escape = Token::simpleMatch(tok->astParent(), "throw") ||
618-
(Token::simpleMatch(tok->astParent(), "return") && !Function::returnsStandardType(scope->function));
617+
const Token* retThrow = tok->astParent();
618+
if (Token::simpleMatch(retThrow, "new"))
619+
retThrow = retThrow->astParent();
620+
const bool escape = Token::simpleMatch(retThrow, "throw") ||
621+
(Token::simpleMatch(retThrow, "return") && !Function::returnsStandardType(scope->function));
619622
std::unordered_set<const Token*> exprs;
620623
for (const ValueFlow::Value& val:tok->values()) {
621624
if (!val.isLocalLifetimeValue() && !val.isSubFunctionLifetimeValue())

0 commit comments

Comments
 (0)