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

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp

Issue 1327913002: Turn a failing assert into an actual check. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
index 02ff1f3aca541002ce07df307e368a7276824b72..5b78013694f9c87853c19a0406b1381a486593d8 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
@@ -136,37 +136,42 @@ CPDF_Dictionary* CPDF_Document::_FindPDFPage(CPDF_Dictionary* pPages,
}
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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698