Chromium Code Reviews| Index: core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp |
| diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp |
| index 5f8d425b96e554a92571f19f4511e27c6ca895b8..9d58e6c347937826cb32b73b0e5d5c56ff7522e0 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,28 @@ 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), |
| + pParams ? pParamsArray->GetDictAt(i) : nullptr}); |
|
Lei Zhang
2016/04/21 00:51:58
Use |pParamsArray| instead of |pParams| and don't
Tom Sepez
2016/04/21 17:48:07
Done.
|
| } |
| } 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; |