From 13aa65a71294cac6e4bdaab73ddd6f4b9fcd8676 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 17 Apr 2018 21:34:18 +0000 Subject: Add ownership to CFX_XMLNode children This CL sets the CFX_XML tree ownership. The pointers set into the tree must be unique_ptrs and the CFX_XMLNode children are set to be either unique_ptrs or UnownedPtrs. Change-Id: Ib0db495c81471e40f5b4533503f7bbe5a784fd77 Reviewed-on: https://pdfium-review.googlesource.com/30711 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_document_parser.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_document_parser.cpp') diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index 62828d71a7..4770d849b1 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -349,7 +349,7 @@ std::unique_ptr CXFA_DocumentParser::LoadXML( ASSERT(pStream); auto root = pdfium::MakeUnique(); - root->AppendChild(new CFX_XMLInstruction(L"xml")); + root->AppendChild(pdfium::MakeUnique(L"xml")); CFX_XMLParser parser(root.get(), pStream); return parser.Parse() ? std::move(root) : nullptr; @@ -674,7 +674,10 @@ CXFA_Node* CXFA_DocumentParser::ParseAsXDPPacket_Data( static_cast(pXMLDocumentNode) ->RemoveAttribute(L"xmlns:xfa"); } - pDataElement->AppendChild(pXMLDocumentNode); + // The node was either removed from the parent above, or already has no + // parent so we can take ownership. + pDataElement->AppendChild( + pdfium::WrapUnique(pXMLDocumentNode)); pDataXMLNode.Reset(std::move(pDataElement)); } if (!pDataXMLNode) -- cgit v1.2.3