From c2f404f993f13d303f9e47d2f97aff727becac7d Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 11 Sep 2018 07:58:38 +0000 Subject: Make RunLengthDecode()'s buffer out parameter a unique_ptr. Change-Id: I1dc99831a564e88035c317455411f1eba9aa41c4 Reviewed-on: https://pdfium-review.googlesource.com/41852 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- core/fpdfapi/page/cpdf_streamparser.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp index fe67634196..69205cb934 100644 --- a/core/fpdfapi/page/cpdf_streamparser.cpp +++ b/core/fpdfapi/page/cpdf_streamparser.cpp @@ -70,16 +70,6 @@ uint32_t DecodeInlineStream(pdfium::span src_span, uint32_t* dest_size) { *dest_buf = nullptr; *dest_size = 0; - if (decoder == "CCITTFaxDecode" || decoder == "CCF") { - std::unique_ptr pDecoder = - CreateFaxDecoder(src_span, width, height, pParam); - return DecodeAllScanlines(std::move(pDecoder), dest_buf, dest_size); - } - std::unique_ptr ignored_result; - if (decoder == "ASCII85Decode" || decoder == "A85") - return A85Decode(src_span, &ignored_result, dest_size); - if (decoder == "ASCIIHexDecode" || decoder == "AHx") - return HexDecode(src_span, &ignored_result, dest_size); if (decoder == "FlateDecode" || decoder == "Fl") { return FlateOrLZWDecode(false, src_span, pParam, *dest_size, dest_buf, dest_size); @@ -93,8 +83,19 @@ uint32_t DecodeInlineStream(pdfium::span src_span, !pParam || pParam->GetIntegerFor("ColorTransform", 1)); return DecodeAllScanlines(std::move(pDecoder), dest_buf, dest_size); } + if (decoder == "CCITTFaxDecode" || decoder == "CCF") { + std::unique_ptr pDecoder = + CreateFaxDecoder(src_span, width, height, pParam); + return DecodeAllScanlines(std::move(pDecoder), dest_buf, dest_size); + } + + std::unique_ptr ignored_result; + if (decoder == "ASCII85Decode" || decoder == "A85") + return A85Decode(src_span, &ignored_result, dest_size); + if (decoder == "ASCIIHexDecode" || decoder == "AHx") + return HexDecode(src_span, &ignored_result, dest_size); if (decoder == "RunLengthDecode" || decoder == "RL") - return RunLengthDecode(src_span, dest_buf, dest_size); + return RunLengthDecode(src_span, &ignored_result, dest_size); return FX_INVALID_OFFSET; } -- cgit v1.2.3