summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-07-23 19:15:14 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-23 19:15:14 +0000
commit2dcf20fa8d3035f4366178654abbfbc95aa9e799 (patch)
treee47d1dccaced6bd7c5725ce403fc4622d0ae4028 /core
parent76a1a353cd600f482261df730549605578eb8f76 (diff)
downloadpdfium-2dcf20fa8d3035f4366178654abbfbc95aa9e799.tar.xz
Add support of rebuilding crossrefs with compressed objects.
Change-Id: I0743c34f0206f85828570430edb9f62b6b0cdbb5 Reviewed-on: https://pdfium-review.googlesource.com/37315 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/parser/cpdf_object_stream.h3
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp13
2 files changed, 14 insertions, 2 deletions
diff --git a/core/fpdfapi/parser/cpdf_object_stream.h b/core/fpdfapi/parser/cpdf_object_stream.h
index 816c1be77e..44aa8f72e5 100644
--- a/core/fpdfapi/parser/cpdf_object_stream.h
+++ b/core/fpdfapi/parser/cpdf_object_stream.h
@@ -33,6 +33,9 @@ class CPDF_ObjectStream {
bool HasObject(uint32_t obj_number) const;
std::unique_ptr<CPDF_Object> ParseObject(CPDF_IndirectObjectHolder* pObjList,
uint32_t obj_number) const;
+ const std::map<uint32_t, uint32_t>& objects_offsets() const {
+ return objects_offsets_;
+ }
protected:
explicit CPDF_ObjectStream(const CPDF_Stream* stream);
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index d4ad0656e6..4d3835795c 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -650,8 +650,6 @@ bool CPDF_Parser::RebuildCrossRef() {
const FX_FILESIZE obj_pos = numbers[0].second;
const uint32_t obj_num = numbers[0].first;
const uint32_t gen_num = numbers[1].first;
- if (obj_num < kMaxObjectNumber)
- cross_ref_table->AddNormal(obj_num, gen_num, obj_pos);
m_pSyntax->SetPos(obj_pos);
const std::unique_ptr<CPDF_Stream> pStream =
@@ -664,6 +662,17 @@ bool CPDF_Parser::RebuildCrossRef() {
pdfium::MakeUnique<CPDF_CrossRefTable>(
ToDictionary(pStream->GetDict()->Clone())));
}
+
+ if (obj_num < kMaxObjectNumber) {
+ cross_ref_table->AddNormal(obj_num, gen_num, obj_pos);
+ if (const auto object_stream =
+ CPDF_ObjectStream::Create(pStream.get())) {
+ for (const auto& it : object_stream->objects_offsets()) {
+ if (it.first < kMaxObjectNumber)
+ cross_ref_table->AddCompressed(it.first, obj_num);
+ }
+ }
+ }
}
numbers.clear();
}