summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-04-22 15:25:14 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-22 15:25:14 -0700
commit90c964fb069bfa9934493481f8ccfefef9c3b3fe (patch)
treec9e3d6ec93f68eb9c241411ec59132761d37d230 /core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp
parent16a2033b3b7e2e348509c9938d77268e85e2b763 (diff)
downloadpdfium-90c964fb069bfa9934493481f8ccfefef9c3b3fe.tar.xz
Add a simple check for V4 cross reference table
Some unknown software generates cross reference table with the claimed object numbers are all off by one. Add a simple verification function to detect this scenario, thus have a chance to rebuild the correct cross reference table. To avoid unnecessary checks and potiential performance hit, we only check for the very first non free entry. BUG=602650 Review URL: https://codereview.chromium.org/1910063004
Diffstat (limited to 'core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp')
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp
index f427ec5d81..042b221554 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "public/fpdf_text.h"
#include "testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -38,3 +39,18 @@ TEST_F(CPDFParserEmbeddertest, Bug_325) {
EXPECT_FALSE(OpenDocument("bug_325_a.pdf"));
EXPECT_FALSE(OpenDocument("bug_325_b.pdf"));
}
+
+TEST_F(CPDFParserEmbeddertest, Bug_602650) {
+ // Test the case that cross reference entries, which are well formed,
+ // but do not match with the objects.
+ EXPECT_TRUE(OpenDocument("bug_602650.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_NE(nullptr, page);
+ FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page);
+ EXPECT_NE(nullptr, text_page);
+ // The page should not be blank.
+ EXPECT_LT(0, FPDFText_CountChars(text_page));
+
+ FPDFText_ClosePage(text_page);
+ UnloadPage(page);
+}