diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-05-02 16:02:03 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-02 16:02:03 +0000 |
commit | 70180648ffd01dd3716871758411d2031aaaebbe (patch) | |
tree | 6cc1d7aa3df8c3e343a1ef6f7e032bae8499f6db /testing | |
parent | 8ab2b2b2869f769dc169b4a96bb67ec596d5278b (diff) | |
download | pdfium-70180648ffd01dd3716871758411d2031aaaebbe.tar.xz |
Add a CFX_XMLDocument class.
This CL adds a CFX_XMLDocument to act as the XML node container. All
nodes are now owned by the document and the document is returned by the
CFX_XMLParser.
Classes which parse XML files now store the document instead of the root
node.
BUG: chromium:835636
Change-Id: I1e07d6115cf14714911d6fd4c3fa920c94fd5faf
Reviewed-on: https://pdfium-review.googlesource.com/31313
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'testing')
-rw-r--r-- | testing/libfuzzer/pdf_xml_fuzzer.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/testing/libfuzzer/pdf_xml_fuzzer.cc b/testing/libfuzzer/pdf_xml_fuzzer.cc index 97b9d3c7cf..a3c399f78d 100644 --- a/testing/libfuzzer/pdf_xml_fuzzer.cc +++ b/testing/libfuzzer/pdf_xml_fuzzer.cc @@ -9,6 +9,7 @@ #include "core/fxcrt/cfx_memorystream.h" #include "core/fxcrt/fx_safe_types.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/xml/cfx_xmldocument.h" #include "core/fxcrt/xml/cfx_xmlelement.h" #include "core/fxcrt/xml/cfx_xmlparser.h" #include "third_party/base/ptr_util.h" @@ -20,12 +21,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { auto stream = pdfium::MakeRetain<CFX_MemoryStream>(const_cast<uint8_t*>(data), size, false); - auto root = pdfium::MakeUnique<CFX_XMLElement>(L"ROOT"); - CFX_XMLParser parser(root.get(), stream); - if (!parser.Parse()) + + CFX_XMLParser parser(stream); + std::unique_ptr<CFX_XMLDocument> doc = parser.Parse(); + if (!doc || !doc->GetRoot()) return 0; - for (CFX_XMLNode* pXMLNode = root->GetFirstChild(); pXMLNode; + for (CFX_XMLNode* pXMLNode = doc->GetRoot()->GetFirstChild(); pXMLNode; pXMLNode = pXMLNode->GetNextSibling()) { if (pXMLNode->GetType() == FX_XMLNODE_Element) break; |