diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 5f8d425b96..3893d9bd41 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -7,6 +7,7 @@ #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include <limits.h> +#include <utility> #include <vector> #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" @@ -342,29 +343,26 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, CPDF_Object* pParams = pDict ? pDict->GetDirectObjectBy("DecodeParms") : nullptr; - std::vector<CFX_ByteString> DecoderList; - CFX_ArrayTemplate<CPDF_Object*> ParamList; + + std::vector<std::pair<CFX_ByteString, CPDF_Object*>> DecoderArray; if (CPDF_Array* pDecoders = pDecoder->AsArray()) { CPDF_Array* pParamsArray = ToArray(pParams); - if (!pParamsArray) - pParams = nullptr; - for (size_t i = 0; i < pDecoders->GetCount(); i++) { - DecoderList.push_back(pDecoders->GetStringAt(i)); - ParamList.Add(pParams ? pParamsArray->GetDictAt(i) : nullptr); + DecoderArray.push_back( + {pDecoders->GetStringAt(i), + pParamsArray ? pParamsArray->GetDictAt(i) : nullptr}); } } else { - DecoderList.push_back(pDecoder->GetString()); - ParamList.Add(pParams ? pParams->GetDict() : nullptr); + DecoderArray.push_back( + {pDecoder->GetString(), pParams ? pParams->GetDict() : nullptr}); } - uint8_t* last_buf = (uint8_t*)src_buf; + uint8_t* last_buf = const_cast<uint8_t*>(src_buf); uint32_t last_size = src_size; - int nSize = pdfium::CollectionSize<int>(DecoderList); + int nSize = pdfium::CollectionSize<int>(DecoderArray); for (int i = 0; i < nSize; i++) { int estimated_size = i == nSize - 1 ? last_estimated_size : 0; - CFX_ByteString decoder = DecoderList[i]; - // Use ToDictionary here because we can push nullptr into the ParamList. - CPDF_Dictionary* pParam = ToDictionary(ParamList[i]); + CFX_ByteString decoder = DecoderArray[i].first; + CPDF_Dictionary* pParam = ToDictionary(DecoderArray[i].second); uint8_t* new_buf = nullptr; uint32_t new_size = (uint32_t)-1; int offset = -1; |