From 437c23363b9be8d681e5ba76827b2fb5af53c8bf Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Thu, 12 Nov 2015 10:52:54 -0800 Subject: Merge to XFA: Clear decoders after the image decoder in the /Filter array. During decoding, when an image decoder is encountered, any subsequent decoders are ignored, but remain in the array. However, later on CPDF_DIBSource::ValidateDictParam expects the image decoder to be the last in the array, causing issues. A check is also added in CPDF_DIBSource::GetScanline to ensure that the calculated pitch value is <= the (4-aligned) pitch value in the cached bitmap to prevent future issues. Also cleans up some NULL usages. BUG=552046 TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1406943005 . (cherry picked from commit 182d129bcee8f7731b9bbfde0064295ad3b37271) Review URL: https://codereview.chromium.org/1436153003 . --- core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to '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 ff0519c9b5..588ab5dff6 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -363,7 +363,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, // Use ToDictionary here because we can push NULL into the ParamList. CPDF_Dictionary* pParam = ToDictionary(static_cast(ParamList[i])); - uint8_t* new_buf = NULL; + uint8_t* new_buf = nullptr; FX_DWORD new_size = (FX_DWORD)-1; int offset = -1; if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { @@ -395,18 +395,21 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, return TRUE; } offset = RunLengthDecode(last_buf, last_size, new_buf, new_size); + } else if (decoder == FX_BSTRC("Crypt")) { + continue; } else { + // If we get here, assume it's an image decoder. if (decoder == FX_BSTRC("DCT")) { decoder = "DCTDecode"; } else if (decoder == FX_BSTRC("CCF")) { decoder = "CCITTFaxDecode"; - } else if (decoder == FX_BSTRC("Crypt")) { - continue; } ImageEncoding = decoder; pImageParms = pParam; dest_buf = (uint8_t*)last_buf; dest_size = last_size; + if (CPDF_Array* pDecoders = pDecoder->AsArray()) + pDecoders->RemoveAt(i + 1, pDecoders->GetCount() - i - 1); return TRUE; } if (last_buf != src_buf) { @@ -420,7 +423,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, last_size = new_size; } ImageEncoding = ""; - pImageParms = NULL; + pImageParms = nullptr; dest_buf = last_buf; dest_size = last_size; return TRUE; -- cgit v1.2.3