Deref of DynTypedNode* must not outlive owning DynTypedNodeList

Change-Id: I8ac4a2f1e442446384b88f38bdef21644409f8a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90303
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2020-03-10 18:57:36 +01:00
parent 17c467a66d
commit 11a78fde3b
2 changed files with 6 additions and 4 deletions

View File

@@ -201,9 +201,10 @@ Stmt* Plugin::getParentStmt( Stmt* stmt )
static const Decl* getFunctionDeclContext(ASTContext& context, const Stmt* stmt)
{
auto it = context.getParents(*stmt).begin();
auto const parents = context.getParents(*stmt);
auto it = parents.begin();
if (it == context.getParents(*stmt).end())
if (it == parents.end())
return nullptr;
const Decl *decl = it->get<Decl>();

View File

@@ -1146,9 +1146,10 @@ bool UnusedFields::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
static const Decl* getFunctionDeclContext(ASTContext& context, const Stmt* stmt)
{
auto it = context.getParents(*stmt).begin();
auto const parents = context.getParents(*stmt);
auto it = parents.begin();
if (it == context.getParents(*stmt).end())
if (it == parents.end())
return nullptr;
const Decl *decl = it->get<Decl>();