summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-20 10:47:41 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-20 18:15:55 +0000
commit03f5bab415cda066855e2672154358056649c584 (patch)
tree587373e43063ca43db94f20fb1e6b15841233df2
parent9a2f69f26c136ef4b53285edc28f4e494997f630 (diff)
downloadpdfium-03f5bab415cda066855e2672154358056649c584.tar.xz
Do not insert null node if ParseAsXDPPacket_Config fails
Doing so trips an assert in the debug build but is harmless otherwise. This appears to be wrong since the beginning of time. Bug: 709793 Change-Id: I179f6944a3f7b2a89efa65a16078f6f58448ba4b Reviewed-on: https://pdfium-review.googlesource.com/4390 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r--testing/resources/bug_709793.in22
-rw-r--r--testing/resources/bug_709793.pdf33
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser_embeddertest.cpp7
4 files changed, 64 insertions, 1 deletions
diff --git a/testing/resources/bug_709793.in b/testing/resources/bug_709793.in
new file mode 100644
index 0000000000..c9fe0882a7
--- /dev/null
+++ b/testing/resources/bug_709793.in
@@ -0,0 +1,22 @@
+{{header}}
+{{object 1 0}} <<
+ /Pages 3 0 R
+ /AcroForm <<
+ /XFA 7 0 R
+ >>
+>>
+endobj
+{{object 3 0}} <<
+>>
+endobj
+{{object 7 0}} <<
+>>stream
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"><config><form/></></>
+endstream
+endobj
+{{xref}}
+trailer <<
+ /Root 1 0 R
+>>
+{{startxref}}
+%%EOF
diff --git a/testing/resources/bug_709793.pdf b/testing/resources/bug_709793.pdf
new file mode 100644
index 0000000000..003c7cf769
--- /dev/null
+++ b/testing/resources/bug_709793.pdf
@@ -0,0 +1,33 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+ /Pages 3 0 R
+ /AcroForm <<
+ /XFA 7 0 R
+ >>
+>>
+endobj
+3 0 obj <<
+>>
+endobj
+7 0 obj <<
+>>stream
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"><config><form/></></>
+endstream
+endobj
+xref
+0 8
+0000000000 65535 f
+0000000015 00000 n
+0000000000 65535 f
+0000000086 00000 n
+0000000000 65535 f
+0000000000 65535 f
+0000000000 65535 f
+0000000107 00000 n
+trailer <<
+ /Root 1 0 R
+>>
+startxref
+212
+%%EOF
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index db15a80a44..4773fda22a 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -485,7 +485,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
pXMLConfigDOMRoot = pChildItem;
pXFAConfigDOMRoot =
ParseAsXDPPacket_Config(pXMLConfigDOMRoot, XFA_XDPPACKET_Config);
- pXFARootNode->InsertChild(pXFAConfigDOMRoot, nullptr);
+ if (pXFAConfigDOMRoot)
+ pXFARootNode->InsertChild(pXFAConfigDOMRoot, nullptr);
}
CFX_XMLNode* pXMLDatasetsDOMRoot = nullptr;
diff --git a/xfa/fxfa/parser/cxfa_simple_parser_embeddertest.cpp b/xfa/fxfa/parser/cxfa_simple_parser_embeddertest.cpp
index a33169646d..174febf9ee 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser_embeddertest.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser_embeddertest.cpp
@@ -13,3 +13,10 @@ TEST_F(CXFASimpleParserEmbeddertest, Bug_216) {
EXPECT_NE(nullptr, page);
UnloadPage(page);
}
+
+TEST_F(CXFASimpleParserEmbeddertest, Bug_709793) {
+ EXPECT_TRUE(OpenDocument("bug_709793.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_NE(nullptr, page);
+ UnloadPage(page);
+}