diff options
author | art-snake <art-snake@yandex-team.ru> | 2016-10-20 13:29:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-20 13:29:45 -0700 |
commit | ef38283688c1ee7c08bcf4204cfb78e09c039782 (patch) | |
tree | e610f19e8b9a3a13b50a4f9a1b37ac33d1b21433 /core/fpdfapi/parser/cpdf_data_avail.cpp | |
parent | 7403f8a2a0d87179a1ccd57ceccd2d84fa59c319 (diff) | |
download | pdfium-ef38283688c1ee7c08bcf4204cfb78e09c039782.tar.xz |
Fix loading page using hint tables.chromium/2897
When linearized document have hint table,
The FPDFAvail_IsPageAvail return true, but
FPDF_LoadPage return nullptr, for non first pages.
This happens, bacause document not use hint tables, to load page.
To fix this, I force save the page's ObjNum in document.
R=npm, dsinclair
Review-Url: https://chromiumcodereview.appspot.com/2437773003
Diffstat (limited to 'core/fpdfapi/parser/cpdf_data_avail.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index e23aa8ecfb..e52d0611f9 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -1625,6 +1625,8 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( nResult = m_pHintTables->CheckPage(dwPage, pHints); if (nResult != DataAvailable) return nResult; + // We should say to the document, which object is the page. + m_pDocument->SetPageObjNum(dwPage, GetPage(dwPage)->GetObjNum()); m_pagesLoadState.insert(dwPage); return DataAvailable; } @@ -1763,11 +1765,18 @@ CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) { uint32_t dwObjNum = 0; bool bPagePosGot = m_pHintTables->GetPagePos(index, &szPageStartPos, &szPageLength, &dwObjNum); + if (!dwObjNum) + return nullptr; + // Page object already can be parsed in document. + CPDF_Object* pPageDict = m_pDocument->GetIndirectObject(dwObjNum); + if (pPageDict) + return pPageDict->GetDict(); + if (!bPagePosGot) return nullptr; m_syntaxParser.InitParser(m_pFileRead, (uint32_t)szPageStartPos); - CPDF_Object* pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); + pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); if (!pPageDict) return nullptr; |