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

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

Issue 1417893003: Add type cast definitions for CPDF_Array. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 514380eeab7cc8e9b1168f244bc454ece8d2eb02..8b822a8b9c686c19724e3680415b7ff50bd422d7 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -1154,17 +1154,14 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos,
}
CPDF_Array* CPDF_Parser::GetIDArray() {
CPDF_Object* pID = m_pTrailer ? m_pTrailer->GetElement(FX_BSTRC("ID")) : NULL;
- if (pID == NULL) {
- return NULL;
- }
+ if (!pID)
+ return nullptr;
+
if (pID->GetType() == PDFOBJ_REFERENCE) {
pID = ParseIndirectObject(NULL, ((CPDF_Reference*)pID)->GetRefObjNum());
m_pTrailer->SetAt(FX_BSTRC("ID"), pID);
}
- if (pID == NULL || pID->GetType() != PDFOBJ_ARRAY) {
- return NULL;
- }
- return (CPDF_Array*)pID;
+ return ToArray(pID);
}
FX_DWORD CPDF_Parser::GetRootObjNum() {
CPDF_Object* pRef =
@@ -3474,7 +3471,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) {
}
continue;
}
- if (pObj->GetType() == PDFOBJ_ARRAY) {
+ if (pObj->IsArray()) {
CPDF_Array* pArray = pObj->GetArray();
if (pArray) {
int32_t iSize = pArray->GetCount();
@@ -3543,7 +3540,7 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) {
m_PageObjList.Add(pKid->GetRefObjNum());
} break;
case PDFOBJ_ARRAY: {
- CPDF_Array* pKidsArray = (CPDF_Array*)pKids;
+ CPDF_Array* pKidsArray = pKids->AsArray();
for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) {
CPDF_Object* pKid = (CPDF_Object*)pKidsArray->GetElement(i);
if (pKid && pKid->GetType() == PDFOBJ_REFERENCE) {
@@ -4116,13 +4113,15 @@ FX_BOOL CPDF_DataAvail::CheckArrayPageNode(FX_DWORD dwPageNo,
}
return FALSE;
}
- if (pPages->GetType() != PDFOBJ_ARRAY) {
+
+ CPDF_Array* pArray = pPages->AsArray();
+ if (!pArray) {
pPages->Release();
m_docStatus = PDF_DATAAVAIL_ERROR;
return FALSE;
}
+
pPageNode->m_type = PDF_PAGENODE_PAGES;
- CPDF_Array* pArray = (CPDF_Array*)pPages;
for (FX_DWORD i = 0; i < pArray->GetCount(); ++i) {
CPDF_Object* pKid = (CPDF_Object*)pArray->GetElement(i);
if (!pKid || pKid->GetType() != PDFOBJ_REFERENCE) {
@@ -4151,7 +4150,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo,
}
return FALSE;
}
- if (pPage->GetType() == PDFOBJ_ARRAY) {
+ if (pPage->IsArray()) {
pPageNode->m_dwPageNo = dwPageNo;
pPageNode->m_type = PDF_PAGENODE_ARRAY;
pPage->Release();
@@ -4180,7 +4179,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo,
pNode->m_dwPageNo = pKid->GetRefObjNum();
} break;
case PDFOBJ_ARRAY: {
- CPDF_Array* pKidsArray = (CPDF_Array*)pKids;
+ CPDF_Array* pKidsArray = pKids->AsArray();
for (FX_DWORD i = 0; i < pKidsArray->GetCount(); ++i) {
CPDF_Object* pKid = (CPDF_Object*)pKidsArray->GetElement(i);
if (!pKid || pKid->GetType() != PDFOBJ_REFERENCE) {
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698