summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-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,