summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2017-09-11 16:35:02 +0300
committerChromium commit bot <commit-bot@chromium.org>2017-09-19 00:06:40 +0000
commit0bf6961663ec38568b9323e66a8c808d9aa726fb (patch)
treea84e6ffbb15d32186d73279fe1181412b88b647a /core/fpdfapi
parent59aa827d6b41443ecfb2afe1d4ab9f0029b9e536 (diff)
downloadpdfium-0bf6961663ec38568b9323e66a8c808d9aa726fb.tar.xz
Simplify CPDF_Parser::LoadCrossRefV4
Change-Id: Ie1170e71fb2d8f87857e68620f27e478a0801d21 Reviewed-on: https://pdfium-review.googlesource.com/13670 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp22
-rw-r--r--core/fpdfapi/parser/cpdf_parser.h2
-rw-r--r--core/fpdfapi/parser/cpdf_parser_unittest.cpp8
3 files changed, 19 insertions, 13 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index b0a8126a3d..9239c5f0d0 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -379,7 +379,7 @@ bool CPDF_Parser::VerifyCrossRefV4() {
}
bool CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
- if (!LoadCrossRefV4(xrefpos, 0, true))
+ if (!LoadCrossRefV4(xrefpos, true))
return false;
std::unique_ptr<CPDF_Dictionary> trailer = LoadTrailerV4();
@@ -411,7 +411,7 @@ bool CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
// SLOW ...
CrossRefList.insert(CrossRefList.begin(), xrefpos);
- LoadCrossRefV4(xrefpos, 0, true);
+ LoadCrossRefV4(xrefpos, true);
std::unique_ptr<CPDF_Dictionary> pDict(LoadTrailerV4());
if (!pDict)
@@ -426,8 +426,12 @@ bool CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
}
for (size_t i = 0; i < CrossRefList.size(); ++i) {
- if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], false))
+ if (!LoadCrossRefV4(CrossRefList[i], false))
return false;
+
+ if (XRefStreamList[i] && !LoadCrossRefV5(&XRefStreamList[i], false))
+ return false;
+
if (i == 0 && !VerifyCrossRefV4())
return false;
}
@@ -466,7 +470,7 @@ bool CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
// SLOW ...
CrossRefList.insert(CrossRefList.begin(), xrefpos);
- LoadCrossRefV4(xrefpos, 0, true);
+ LoadCrossRefV4(xrefpos, true);
std::unique_ptr<CPDF_Dictionary> pDict(LoadTrailerV4());
if (!pDict)
@@ -481,7 +485,10 @@ bool CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
}
for (size_t i = 1; i < CrossRefList.size(); ++i) {
- if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], false))
+ if (!LoadCrossRefV4(CrossRefList[i], false))
+ return false;
+
+ if (XRefStreamList[i] && !LoadCrossRefV5(&XRefStreamList[i], false))
return false;
}
return true;
@@ -622,7 +629,6 @@ bool CPDF_Parser::ParseCrossRefV4(std::vector<CrossRefObjData>* out_objects) {
}
bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
- FX_FILESIZE streampos,
bool bSkip) {
m_pSyntax->SetPos(pos);
std::vector<CrossRefObjData> objects;
@@ -631,7 +637,7 @@ bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
MergeCrossRefObjectsData(objects);
- return !streampos || LoadCrossRefV5(&streampos, false);
+ return true;
}
void CPDF_Parser::MergeCrossRefObjectsData(
@@ -1359,7 +1365,7 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
FX_FILESIZE dwFirstXRefOffset = m_pSyntax->GetPos();
bool bXRefRebuilt = false;
- bool bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, 0, false);
+ bool bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, false);
if (!bLoadV4 && !LoadCrossRefV5(&dwFirstXRefOffset, true)) {
if (!RebuildCrossRef())
return FORMAT_ERROR;
diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h
index 20bd6be9b4..5cd1301ddd 100644
--- a/core/fpdfapi/parser/cpdf_parser.h
+++ b/core/fpdfapi/parser/cpdf_parser.h
@@ -122,7 +122,7 @@ class CPDF_Parser {
std::unique_ptr<CPDF_SyntaxParser> m_pSyntax;
std::map<uint32_t, ObjectInfo> m_ObjectInfo;
- bool LoadCrossRefV4(FX_FILESIZE pos, FX_FILESIZE streampos, bool bSkip);
+ bool LoadCrossRefV4(FX_FILESIZE pos, bool bSkip);
bool RebuildCrossRef();
private:
diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
index 25c22c701b..d441b12cef 100644
--- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
@@ -116,7 +116,7 @@ TEST(cpdf_parser, LoadCrossRefV4) {
ASSERT_TRUE(
parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
- ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false));
+ ASSERT_TRUE(parser.LoadCrossRefV4(0, false));
const FX_FILESIZE offsets[] = {0, 17, 81, 0, 331, 409};
const CPDF_Parser::ObjectType types[] = {
CPDF_Parser::ObjectType::kFree,
@@ -147,7 +147,7 @@ TEST(cpdf_parser, LoadCrossRefV4) {
ASSERT_TRUE(
parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
- ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false));
+ ASSERT_TRUE(parser.LoadCrossRefV4(0, false));
const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0,
0, 25518, 25635, 0, 0, 25777};
const CPDF_Parser::ObjectType types[] = {
@@ -186,7 +186,7 @@ TEST(cpdf_parser, LoadCrossRefV4) {
ASSERT_TRUE(
parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
- ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false));
+ ASSERT_TRUE(parser.LoadCrossRefV4(0, false));
const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0,
0, 0, 25635, 0, 0, 25777};
const CPDF_Parser::ObjectType types[] = {
@@ -224,7 +224,7 @@ TEST(cpdf_parser, LoadCrossRefV4) {
ASSERT_TRUE(
parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
- ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false));
+ ASSERT_TRUE(parser.LoadCrossRefV4(0, false));
const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179};
const CPDF_Parser::ObjectType types[] = {
CPDF_Parser::ObjectType::kFree,