summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-09-10 12:06:15 -0700
committerLei Zhang <thestig@chromium.org>2015-09-10 12:06:15 -0700
commit95d618eb0508dcf650cc43cc08be69dcbc9d9f4d (patch)
tree5489b139d2dc88acd7ba705f3f188e9d8f303cec
parent496d9484da9332ba7abf7430ff7b474902ad546f (diff)
downloadpdfium-95d618eb0508dcf650cc43cc08be69dcbc9d9f4d.tar.xz
Merge to M45: Turn a failing assert into an actual check.
BUG=522131 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1327913002 . (cherry picked from commit 640c395fa9b76552383ccd0c5f4668ea698089f6) Review URL: https://codereview.chromium.org/1333013002 .
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
index c0f45c5379..da53e85884 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
@@ -141,38 +141,41 @@ CPDF_Dictionary* CPDF_Document::_FindPDFPage(CPDF_Dictionary* pPages, int iPage,
}
return NULL;
}
+
CPDF_Dictionary* CPDF_Document::GetPage(int iPage)
{
- if (iPage < 0 || iPage >= m_PageList.GetSize()) {
- return NULL;
- }
+ if (iPage < 0 || iPage >= m_PageList.GetSize())
+ return nullptr;
+
if (m_bLinearized && (iPage == (int)m_dwFirstPageNo)) {
CPDF_Object* pObj = GetIndirectObject(m_dwFirstPageObjNum);
if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) {
- return (CPDF_Dictionary*)pObj;
+ return static_cast<CPDF_Dictionary*>(pObj);
}
}
int objnum = m_PageList.GetAt(iPage);
if (objnum) {
CPDF_Object* pObj = GetIndirectObject(objnum);
- ASSERT(pObj->GetType() == PDFOBJ_DICTIONARY);
- return (CPDF_Dictionary*)pObj;
+ if (pObj && pObj->GetType() == PDFOBJ_DICTIONARY) {
+ return static_cast<CPDF_Dictionary*>(pObj);
+ }
}
CPDF_Dictionary* pRoot = GetRoot();
- if (pRoot == NULL) {
- return NULL;
- }
+ if (!pRoot)
+ return nullptr;
+
CPDF_Dictionary* pPages = pRoot->GetDict(FX_BSTRC("Pages"));
- if (pPages == NULL) {
- return NULL;
- }
+ if (!pPages)
+ return nullptr;
+
CPDF_Dictionary* pPage = _FindPDFPage(pPages, iPage, iPage, 0);
- if (pPage == NULL) {
- return NULL;
- }
+ if (!pPage)
+ return nullptr;
+
m_PageList.SetAt(iPage, pPage->GetObjNum());
return pPage;
}
+
int CPDF_Document::_FindPageIndex(CPDF_Dictionary* pNode, FX_DWORD& skip_count, FX_DWORD objnum, int& index, int level)
{
if (pNode->KeyExist(FX_BSTRC("Kids"))) {