Chromium Code Reviews| Index: 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 e23aa8ecfbd6bc063d11c1be8c70ed17211884ce..e52d0611f973867ac99cda381837d1872df6f787 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()); |
|
Lei Zhang
2016/10/20 21:43:36
Can GetPage() return a nullptr here?
Lei Zhang
2016/10/21 17:15:53
Based on the new crashes that caused this revert..
snake
2016/10/24 15:38:31
But should not, because the page should be availab
|
| 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) |
|
Lei Zhang
2016/10/20 21:43:36
You should check |bPagePosGot| first, because if i
|
| + 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; |