Add a test case for a DCHECK() failure inside FPDF_SaveAsCopy().
Add a simple FPDFSaveEmbedderTest test case that calls FPDF_SaveAsCopy()
on a malformed PDF. The test case starts out disabled because it
currently triggers the bug.
Bug: chromium:1328389
Change-Id: I944cebaa1b4f57e74a7aeffe79ea9b5e313b71ed
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93910
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Nigi <nigi@chromium.org>
diff --git a/fpdfsdk/fpdf_save_embeddertest.cpp b/fpdfsdk/fpdf_save_embeddertest.cpp
index f9279ce..7bada3b 100644
--- a/fpdfsdk/fpdf_save_embeddertest.cpp
+++ b/fpdfsdk/fpdf_save_embeddertest.cpp
@@ -178,3 +178,10 @@
EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
EXPECT_THAT(GetString(), testing::HasSubstr("/Length 0"));
}
+
+// Should not trigger a DCHECK() failure in CFX_FileBufferArchive.
+// TODO(crbug.com/1328389): Fix the bug so the test can be enabled.
+TEST_F(FPDFSaveEmbedderTest, DISABLED_Bug1328389) {
+ ASSERT_TRUE(OpenDocument("bug_1328389.pdf"));
+ EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
+}
diff --git a/testing/resources/bug_1328389.in b/testing/resources/bug_1328389.in
new file mode 100644
index 0000000..3370ce7
--- /dev/null
+++ b/testing/resources/bug_1328389.in
@@ -0,0 +1,24 @@
+{{header}}
+{{object 1 0}} <<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+{{object 2 0}} <<
+ /Type /Pages
+ /Kids [3 0 R]
+ /Count 1
+>>
+endobj
+{{object 3 0}} <<
+ /Type /Page
+ /Parent 2 0 R
+ /MediaBox [0 0 100 100]
+ % https://crbug.com/1328389
+ /Foo /
+>>
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/bug_1328389.pdf b/testing/resources/bug_1328389.pdf
new file mode 100644
index 0000000..e45a7a8
--- /dev/null
+++ b/testing/resources/bug_1328389.pdf
@@ -0,0 +1,34 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+2 0 obj <<
+ /Type /Pages
+ /Kids [3 0 R]
+ /Count 1
+>>
+endobj
+3 0 obj <<
+ /Type /Page
+ /Parent 2 0 R
+ /MediaBox [0 0 100 100]
+ % https://crbug.com/1328389
+ /Foo /
+>>
+endobj
+xref
+0 4
+0000000000 65535 f
+0000000015 00000 n
+0000000068 00000 n
+0000000131 00000 n
+trailer <<
+ /Root 1 0 R
+ /Size 4
+>>
+startxref
+247
+%%EOF