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 35c1a5892b44d12d19543e2dfb043b0cb33c8320..6839c07c072d38d5fcfa2bb0ab4f41d146d6deb1 100644 |
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp |
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp |
@@ -277,8 +277,8 @@ FX_DWORD CPDF_Parser::SetEncryptHandler() { |
} |
CPDF_Object* pEncryptObj = m_pTrailer->GetElement(FX_BSTRC("Encrypt")); |
if (pEncryptObj) { |
- if (pEncryptObj->GetType() == PDFOBJ_DICTIONARY) { |
- SetEncryptDictionary((CPDF_Dictionary*)pEncryptObj); |
+ if (CPDF_Dictionary* pEncryptDict = pEncryptObj->AsDictionary()) { |
+ SetEncryptDictionary(pEncryptDict); |
} else if (pEncryptObj->GetType() == PDFOBJ_REFERENCE) { |
pEncryptObj = m_pDocument->GetIndirectObject( |
((CPDF_Reference*)pEncryptObj)->GetRefObjNum()); |
@@ -804,7 +804,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { |
if (m_pTrailer) { |
m_pTrailer->Release(); |
} |
- m_pTrailer = (CPDF_Dictionary*)pDict->Clone(); |
+ m_pTrailer = ToDictionary(pDict->Clone()); |
} |
} |
} |
@@ -857,15 +857,14 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { |
m_Syntax.RestorePos(pos + i - m_Syntax.m_HeaderOffset); |
CPDF_Object* pObj = m_Syntax.GetObject(m_pDocument, 0, 0, 0); |
if (pObj) { |
- if (pObj->GetType() != PDFOBJ_DICTIONARY && |
- pObj->GetType() != PDFOBJ_STREAM) { |
+ if (!pObj->IsDictionary() && pObj->GetType() != PDFOBJ_STREAM) { |
pObj->Release(); |
} else { |
CPDF_Dictionary* pTrailer = NULL; |
if (pObj->GetType() == PDFOBJ_STREAM) { |
pTrailer = ((CPDF_Stream*)pObj)->GetDict(); |
} else { |
- pTrailer = (CPDF_Dictionary*)pObj; |
+ pTrailer = pObj->AsDictionary(); |
} |
if (pTrailer) { |
if (m_pTrailer) { |
@@ -890,7 +889,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { |
} |
} else { |
if (pObj->GetType() == PDFOBJ_STREAM) { |
- m_pTrailer = (CPDF_Dictionary*)pTrailer->Clone(); |
+ m_pTrailer = ToDictionary(pTrailer->Clone()); |
pObj->Release(); |
} else { |
m_pTrailer = pTrailer; |
@@ -1034,13 +1033,13 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos, |
return FALSE; |
} |
if (bMainXRef) { |
- m_pTrailer = (CPDF_Dictionary*)pStream->GetDict()->Clone(); |
+ m_pTrailer = ToDictionary(pStream->GetDict()->Clone()); |
m_CrossRef.SetSize(size); |
if (m_V5Type.SetSize(size)) { |
FXSYS_memset(m_V5Type.GetData(), 0, size); |
} |
} else { |
- m_Trailers.Add((CPDF_Dictionary*)pStream->GetDict()->Clone()); |
+ m_Trailers.Add(ToDictionary(pStream->GetDict()->Clone())); |
} |
std::vector<std::pair<int32_t, int32_t> > arrIndex; |
CPDF_Array* pArray = pStream->GetDict()->GetArray(FX_BSTRC("Index")); |
@@ -1490,9 +1489,9 @@ CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() { |
nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj( |
m_Syntax.GetObject(m_pDocument, 0, 0, 0)); |
- if (!pObj || pObj->GetType() != PDFOBJ_DICTIONARY) |
+ if (!ToDictionary(pObj.get())) |
return nullptr; |
- return static_cast<CPDF_Dictionary*>(pObj.release()); |
+ return pObj.release()->AsDictionary(); |
} |
FX_DWORD CPDF_Parser::GetPermissions(FX_BOOL bCheckRevision) { |
@@ -3496,7 +3495,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(IFX_DownloadHints* pHints) { |
} |
} |
} |
- if (pObj->GetType() != PDFOBJ_DICTIONARY) { |
+ if (!pObj->IsDictionary()) { |
pObj->Release(); |
continue; |
} |
@@ -4049,7 +4048,7 @@ FX_BOOL CPDF_DataAvail::CheckTrailer(IFX_DownloadHints* pHints) { |
pHints->AddSegment(m_Pos, iTrailerSize); |
return FALSE; |
} |
- if (pTrailer->GetType() != PDFOBJ_DICTIONARY) |
+ if (!pTrailer->IsDictionary()) |
return FALSE; |
CPDF_Dictionary* pTrailerDict = pTrailer->GetDict(); |
@@ -4164,7 +4163,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(FX_DWORD dwPageNo, |
pPage->Release(); |
return TRUE; |
} |
- if (pPage->GetType() != PDFOBJ_DICTIONARY) { |
+ if (!pPage->IsDictionary()) { |
pPage->Release(); |
m_docStatus = PDF_DATAAVAIL_ERROR; |
return FALSE; |