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

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.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_decode.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index cbbfbd719766e71e58814a0a0603b0f00194d419..1815d401949ba5aa25ee3b188cc6ea10e84c98da 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -331,31 +331,27 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
{
CPDF_Object* pDecoder =
- pDict ? pDict->GetElementValue(FX_BSTRC("Filter")) : NULL;
- if (!pDecoder || (pDecoder->GetType() != PDFOBJ_ARRAY && !pDecoder->IsName()))
+ pDict ? pDict->GetElementValue(FX_BSTRC("Filter")) : nullptr;
+ if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName()))
return FALSE;
CPDF_Object* pParams =
- pDict ? pDict->GetElementValue(FX_BSTRC("DecodeParms")) : NULL;
+ pDict ? pDict->GetElementValue(FX_BSTRC("DecodeParms")) : nullptr;
CFX_ByteStringArray DecoderList;
CFX_PtrArray ParamList;
- if (pDecoder->GetType() == PDFOBJ_ARRAY) {
- if (pParams && pParams->GetType() != PDFOBJ_ARRAY) {
- pParams = NULL;
- }
- CPDF_Array* pDecoders = (CPDF_Array*)pDecoder;
+ if (CPDF_Array* pDecoders = pDecoder->AsArray()) {
+ CPDF_Array* pParamsArray = ToArray(pParams);
+ if (!pParamsArray)
+ pParams = nullptr;
+
for (FX_DWORD i = 0; i < pDecoders->GetCount(); i++) {
CFX_ByteStringC str = pDecoders->GetConstString(i);
DecoderList.Add(str);
- if (pParams) {
- ParamList.Add(((CPDF_Array*)pParams)->GetDict(i));
- } else {
- ParamList.Add(NULL);
- }
+ ParamList.Add(pParams ? pParamsArray->GetDict(i) : nullptr);
}
} else {
DecoderList.Add(pDecoder->GetConstString());
- ParamList.Add(pParams ? pParams->GetDict() : NULL);
+ ParamList.Add(pParams ? pParams->GetDict() : nullptr);
}
uint8_t* last_buf = (uint8_t*)src_buf;
FX_DWORD last_size = src_size;
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698