Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: core/fpdfapi/parser/cpdf_data_avail.cpp

Issue 2437773003: Fix loading page using hint tables. (Closed)
Patch Set: fix compilation on linux. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/parser/cpdf_data_avail.h" 7 #include "core/fpdfapi/parser/cpdf_data_avail.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 } 1618 }
1619 1619
1620 DocAvailStatus nResult = CheckLinearizedData(pHints); 1620 DocAvailStatus nResult = CheckLinearizedData(pHints);
1621 if (nResult != DataAvailable) 1621 if (nResult != DataAvailable)
1622 return nResult; 1622 return nResult;
1623 1623
1624 if (m_pHintTables) { 1624 if (m_pHintTables) {
1625 nResult = m_pHintTables->CheckPage(dwPage, pHints); 1625 nResult = m_pHintTables->CheckPage(dwPage, pHints);
1626 if (nResult != DataAvailable) 1626 if (nResult != DataAvailable)
1627 return nResult; 1627 return nResult;
1628 // We should say to the document, which object is the page.
1629 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
1628 m_pagesLoadState.insert(dwPage); 1630 m_pagesLoadState.insert(dwPage);
1629 return DataAvailable; 1631 return DataAvailable;
1630 } 1632 }
1631 1633
1632 if (m_bMainXRefLoadedOK) { 1634 if (m_bMainXRefLoadedOK) {
1633 if (m_bTotalLoadPageTree) { 1635 if (m_bTotalLoadPageTree) {
1634 if (!LoadPages(pHints)) 1636 if (!LoadPages(pHints))
1635 return DataNotAvailable; 1637 return DataNotAvailable;
1636 } else { 1638 } else {
1637 if (!m_bCurPageDictLoadOK && !CheckPage(dwPage, pHints)) 1639 if (!m_bCurPageDictLoadOK && !CheckPage(dwPage, pHints))
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 CPDF_Dictionary* pDict = m_pLinearized->GetDict(); 1758 CPDF_Dictionary* pDict = m_pLinearized->GetDict();
1757 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("P") : nullptr; 1759 CPDF_Object* pObj = pDict ? pDict->GetDirectObjectFor("P") : nullptr;
1758 1760
1759 int pageNum = pObj ? pObj->GetInteger() : 0; 1761 int pageNum = pObj ? pObj->GetInteger() : 0;
1760 if (m_pHintTables && index != pageNum) { 1762 if (m_pHintTables && index != pageNum) {
1761 FX_FILESIZE szPageStartPos = 0; 1763 FX_FILESIZE szPageStartPos = 0;
1762 FX_FILESIZE szPageLength = 0; 1764 FX_FILESIZE szPageLength = 0;
1763 uint32_t dwObjNum = 0; 1765 uint32_t dwObjNum = 0;
1764 bool bPagePosGot = m_pHintTables->GetPagePos(index, &szPageStartPos, 1766 bool bPagePosGot = m_pHintTables->GetPagePos(index, &szPageStartPos,
1765 &szPageLength, &dwObjNum); 1767 &szPageLength, &dwObjNum);
1768 if (!dwObjNum)
Lei Zhang 2016/10/20 21:43:36 You should check |bPagePosGot| first, because if i
1769 return nullptr;
1770 // Page object already can be parsed in document.
1771 CPDF_Object* pPageDict = m_pDocument->GetIndirectObject(dwObjNum);
1772 if (pPageDict)
1773 return pPageDict->GetDict();
1774
1766 if (!bPagePosGot) 1775 if (!bPagePosGot)
1767 return nullptr; 1776 return nullptr;
1768 1777
1769 m_syntaxParser.InitParser(m_pFileRead, (uint32_t)szPageStartPos); 1778 m_syntaxParser.InitParser(m_pFileRead, (uint32_t)szPageStartPos);
1770 CPDF_Object* pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument); 1779 pPageDict = ParseIndirectObjectAt(0, dwObjNum, m_pDocument);
1771 if (!pPageDict) 1780 if (!pPageDict)
1772 return nullptr; 1781 return nullptr;
1773 1782
1774 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration(dwObjNum, 1783 if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration(dwObjNum,
1775 pPageDict)) { 1784 pPageDict)) {
1776 return nullptr; 1785 return nullptr;
1777 } 1786 }
1778 return pPageDict->GetDict(); 1787 return pPageDict->GetDict();
1779 } 1788 }
1780 } 1789 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 return FormAvailable; 1825 return FormAvailable;
1817 } 1826 }
1818 1827
1819 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {} 1828 CPDF_DataAvail::PageNode::PageNode() : m_type(PDF_PAGENODE_UNKNOWN) {}
1820 1829
1821 CPDF_DataAvail::PageNode::~PageNode() { 1830 CPDF_DataAvail::PageNode::~PageNode() {
1822 for (int32_t i = 0; i < m_childNode.GetSize(); ++i) 1831 for (int32_t i = 0; i < m_childNode.GetSize(); ++i)
1823 delete m_childNode[i]; 1832 delete m_childNode[i];
1824 m_childNode.RemoveAll(); 1833 m_childNode.RemoveAll();
1825 } 1834 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698