summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_nodeowner.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-02-15 18:12:29 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-15 18:12:29 +0000
commite40678ed8a22ecd57421877af39cf7f281f618c4 (patch)
tree50bbf114829ad3b4852b3739f65c6385091c4ba0 /xfa/fxfa/parser/cxfa_nodeowner.cpp
parent625e6fec9ddd1d023116f7bd22d2192ef9bc49c8 (diff)
downloadpdfium-e40678ed8a22ecd57421877af39cf7f281f618c4.tar.xz
Make the CFX_XMLNode a MaybeOwned pointer
This CL removes the HasOwnXML flag from the CXFA_Node objects and instead uses a MaybeOwned pointer to keep track of the XML nodes. Change-Id: Ie678258247ec21ecb15c639647b189e140586d25 Reviewed-on: https://pdfium-review.googlesource.com/26811 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_nodeowner.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_nodeowner.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_nodeowner.cpp b/xfa/fxfa/parser/cxfa_nodeowner.cpp
index ae6f589616..63f2f717c2 100644
--- a/xfa/fxfa/parser/cxfa_nodeowner.cpp
+++ b/xfa/fxfa/parser/cxfa_nodeowner.cpp
@@ -15,6 +15,19 @@ CXFA_NodeOwner::CXFA_NodeOwner() = default;
CXFA_NodeOwner::~CXFA_NodeOwner() = default;
+void CXFA_NodeOwner::ReleaseXMLNodesIfNeeded() {
+ // Because we don't know what order we'll free the nodes we may end up
+ // destroying the XML tree before nodes have been cleaned up that point into
+ // it. This will cause the ProbeForLowSeverityLifetimeIssue to fire.
+ //
+ // This doesn't happen in the destructor because of the ownership semantics
+ // between the CXFA_Document and CXFA_SimpleParser. It has to happen before
+ // the simple parser is destroyed, but the document has to live longer then
+ // the simple parser.
+ for (auto& it : nodes_)
+ it->ReleaseXMLNodeIfUnowned();
+}
+
CXFA_Node* CXFA_NodeOwner::AddOwnedNode(std::unique_ptr<CXFA_Node> node) {
if (!node)
return nullptr;