summaryrefslogtreecommitdiff
path: root/core/fxcrt/xml/cfx_xmlparser.cpp
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2018-04-17 21:34:18 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-17 21:34:18 +0000
commit13aa65a71294cac6e4bdaab73ddd6f4b9fcd8676 (patch)
tree478874bff3e2831949884adfe750a4924832eb54 /core/fxcrt/xml/cfx_xmlparser.cpp
parent35939f83e45b67de4ccc8c3e70e5e00be40326b6 (diff)
downloadpdfium-13aa65a71294cac6e4bdaab73ddd6f4b9fcd8676.tar.xz
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 <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cfx_xmlparser.cpp')
-rw-r--r--core/fxcrt/xml/cfx_xmlparser.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp
index 9336c11f87..9be8da76b4 100644
--- a/core/fxcrt/xml/cfx_xmlparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include <cwctype>
#include <iterator>
+#include <utility>
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_extension.h"
@@ -177,20 +178,23 @@ bool CFX_XMLParser::Parse() {
case FX_XmlSyntaxResult::TargetName:
m_ws1 = GetTargetName();
if (m_ws1 == L"originalXFAVersion" || m_ws1 == L"acrobat") {
- m_pChild = new CFX_XMLInstruction(m_ws1);
- m_pParent->AppendChild(m_pChild);
+ auto child = pdfium::MakeUnique<CFX_XMLInstruction>(m_ws1);
+ m_pChild = child.get();
+ m_pParent->AppendChild(std::move(child));
} else {
m_pChild = nullptr;
}
m_ws1.clear();
break;
- case FX_XmlSyntaxResult::TagName:
+ case FX_XmlSyntaxResult::TagName: {
m_ws1 = GetTagName();
- m_pChild = new CFX_XMLElement(m_ws1);
- m_pParent->AppendChild(m_pChild);
+ auto child = pdfium::MakeUnique<CFX_XMLElement>(m_ws1);
+ m_pChild = child.get();
+ m_pParent->AppendChild(std::move(child));
m_NodeStack.push(m_pChild);
m_pParent = m_pChild;
break;
+ }
case FX_XmlSyntaxResult::AttriName:
m_ws1 = GetAttributeName();
break;
@@ -201,18 +205,22 @@ bool CFX_XMLParser::Parse() {
}
m_ws1.clear();
break;
- case FX_XmlSyntaxResult::Text:
+ case FX_XmlSyntaxResult::Text: {
m_ws1 = GetTextData();
- m_pChild = new CFX_XMLText(m_ws1);
- m_pParent->AppendChild(m_pChild);
+ auto child = pdfium::MakeUnique<CFX_XMLText>(m_ws1);
+ m_pChild = child.get();
+ m_pParent->AppendChild(std::move(child));
m_pChild = m_pParent;
break;
- case FX_XmlSyntaxResult::CData:
+ }
+ case FX_XmlSyntaxResult::CData: {
m_ws1 = GetTextData();
- m_pChild = new CFX_XMLCharData(m_ws1);
- m_pParent->AppendChild(m_pChild);
+ auto child = pdfium::MakeUnique<CFX_XMLCharData>(m_ws1);
+ m_pChild = child.get();
+ m_pParent->AppendChild(std::move(child));
m_pChild = m_pParent;
break;
+ }
case FX_XmlSyntaxResult::TargetData:
if (m_pChild) {
if (m_pChild->GetType() != FX_XMLNODE_Instruction)