summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-06-14 14:30:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-14 14:30:07 +0000
commite16ffd4fc3f286ebfaf7820351d4fee680deca88 (patch)
tree42f8b04ae604242c9779ac97c17365abd0b3e7f6 /core/fpdfapi/parser
parent8e631772e34256ca2f3bb86a1e23cca34fe8d4fa (diff)
downloadpdfium-e16ffd4fc3f286ebfaf7820351d4fee680deca88.tar.xz
Simplify the calculation of Pages Offsets within CPDF_HintsTable.chromium/3460
Change-Id: I020fd5ae11b32f753d681e7e0c26b7f95e920bff Reviewed-on: https://pdfium-review.googlesource.com/15812 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r--core/fpdfapi/parser/cpdf_hint_tables.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/core/fpdfapi/parser/cpdf_hint_tables.cpp b/core/fpdfapi/parser/cpdf_hint_tables.cpp
index a412fdc34d..7d371909e9 100644
--- a/core/fpdfapi/parser/cpdf_hint_tables.cpp
+++ b/core/fpdfapi/parser/cpdf_hint_tables.cpp
@@ -156,28 +156,21 @@ bool CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
dwPageLenArray.push_back(safePageLen.ValueOrDie());
}
- const FX_FILESIZE nOffsetE = m_pLinearized->GetFirstPageEndOffset();
const uint32_t nFirstPageNum = m_pLinearized->GetFirstPageNo();
+ if (nFirstPageNum >= nPages)
+ return false;
+
+ m_szPageOffsetArray.resize(nPages, 0);
+ ASSERT(m_szFirstPageObjOffset);
+ m_szPageOffsetArray[nFirstPageNum] = m_szFirstPageObjOffset;
+ FX_FILESIZE prev_page_offset = m_pLinearized->GetFirstPageEndOffset();
for (uint32_t i = 0; i < nPages; ++i) {
- if (i == nFirstPageNum) {
- m_szPageOffsetArray.push_back(m_szFirstPageObjOffset);
- } else if (i == nFirstPageNum + 1) {
- if (i == 1) {
- m_szPageOffsetArray.push_back(nOffsetE);
- } else {
- m_szPageOffsetArray.push_back(m_szPageOffsetArray[i - 2] +
- dwPageLenArray[i - 2]);
- }
- } else {
- if (i == 0) {
- m_szPageOffsetArray.push_back(nOffsetE);
- } else {
- m_szPageOffsetArray.push_back(m_szPageOffsetArray[i - 1] +
- dwPageLenArray[i - 1]);
- }
- }
- }
+ if (i == nFirstPageNum)
+ continue;
+ m_szPageOffsetArray[i] = prev_page_offset;
+ prev_page_offset += dwPageLenArray[i];
+ }
m_szPageOffsetArray.push_back(m_szPageOffsetArray[nPages - 1] +
dwPageLenArray[nPages - 1]);
hStream->ByteAlign();