From 995a601c50874729ac40e2cc444b8894cf2aea96 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Tue, 20 Jun 2017 17:42:39 -0400 Subject: Cleanup fpdf_parser_decode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL fixes some nits in fpdf_parser_decode, especially avoiding non-const reference parameters. Change-Id: Ibb914850afd924bb398f886ac862f7589519ef7e Reviewed-on: https://pdfium-review.googlesource.com/6750 Commit-Queue: Nicolás Peña Reviewed-by: dsinclair --- core/fpdfapi/page/cpdf_streamparser.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'core/fpdfapi/page/cpdf_streamparser.cpp') diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp index c3dc54a734..37ab857816 100644 --- a/core/fpdfapi/page/cpdf_streamparser.cpp +++ b/core/fpdfapi/page/cpdf_streamparser.cpp @@ -36,8 +36,8 @@ const uint32_t kMaxWordBuffer = 256; const FX_STRSIZE kMaxStringLength = 32767; uint32_t DecodeAllScanlines(std::unique_ptr pDecoder, - uint8_t*& dest_buf, - uint32_t& dest_size) { + uint8_t** dest_buf, + uint32_t* dest_size) { if (!pDecoder) return FX_INVALID_OFFSET; int ncomps = pDecoder->CountComps(); @@ -48,14 +48,14 @@ uint32_t DecodeAllScanlines(std::unique_ptr pDecoder, if (height == 0 || pitch > (1 << 30) / height) return FX_INVALID_OFFSET; - dest_buf = FX_Alloc2D(uint8_t, pitch, height); - dest_size = pitch * height; // Safe since checked alloc returned. - for (int row = 0; row < height; row++) { + *dest_buf = FX_Alloc2D(uint8_t, pitch, height); + *dest_size = pitch * height; // Safe since checked alloc returned. + for (int row = 0; row < height; ++row) { const uint8_t* pLine = pDecoder->GetScanline(row); if (!pLine) break; - memcpy(dest_buf + row * pitch, pLine, pitch); + memcpy(*dest_buf + row * pitch, pLine, pitch); } return pDecoder->GetSrcOffset(); } @@ -66,8 +66,8 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, int height, const CFX_ByteString& decoder, CPDF_Dictionary* pParam, - uint8_t*& dest_buf, - uint32_t& dest_size) { + uint8_t** dest_buf, + uint32_t* dest_size) { if (decoder == "CCITTFaxDecode" || decoder == "CCF") { std::unique_ptr pDecoder = FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam); @@ -78,7 +78,7 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, if (decoder == "ASCIIHexDecode" || decoder == "AHx") return HexDecode(src_buf, limit, dest_buf, dest_size); if (decoder == "FlateDecode" || decoder == "Fl") { - return FPDFAPI_FlateOrLZWDecode(false, src_buf, limit, pParam, dest_size, + return FPDFAPI_FlateOrLZWDecode(false, src_buf, limit, pParam, *dest_size, dest_buf, dest_size); } if (decoder == "LZWDecode" || decoder == "LZW") { @@ -94,8 +94,8 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, } if (decoder == "RunLengthDecode" || decoder == "RL") return RunLengthDecode(src_buf, limit, dest_buf, dest_size); - dest_size = 0; - dest_buf = 0; + *dest_size = 0; + *dest_buf = 0; return 0xFFFFFFFF; } @@ -194,7 +194,7 @@ std::unique_ptr CPDF_StreamParser::ReadInlineStream( uint32_t dwDestSize = OrigSize; dwStreamSize = PDF_DecodeInlineStream(m_pBuf + m_Pos, m_Size - m_Pos, width, height, - Decoder, pParam, pIgnore, dwDestSize); + Decoder, pParam, &pIgnore, &dwDestSize); FX_Free(pIgnore); if (static_cast(dwStreamSize) < 0) return nullptr; -- cgit v1.2.3