summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_streamparser.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-06-20 17:42:39 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-20 22:10:32 +0000
commit995a601c50874729ac40e2cc444b8894cf2aea96 (patch)
treef2429607324df0be7585c2099505444e0247ef1f /core/fpdfapi/page/cpdf_streamparser.cpp
parentdce2d72f9fbc166ee8eed0e362ab26e1e1a33cdd (diff)
downloadpdfium-995a601c50874729ac40e2cc444b8894cf2aea96.tar.xz
Cleanup fpdf_parser_decode
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 <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_streamparser.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp24
1 files changed, 12 insertions, 12 deletions
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<CCodec_ScanlineDecoder> 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<CCodec_ScanlineDecoder> 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<CCodec_ScanlineDecoder> 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_Stream> 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<int>(dwStreamSize) < 0)
return nullptr;