From ef38283688c1ee7c08bcf4204cfb78e09c039782 Mon Sep 17 00:00:00 2001 From: art-snake Date: Thu, 20 Oct 2016 13:29:45 -0700 Subject: Fix loading page using hint tables. 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 --- core/fpdfapi/parser/cpdf_data_avail.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'core/fpdfapi/parser/cpdf_data_avail.cpp') 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; -- cgit v1.2.3