From 87a12747eafe83b88502b546ed3ef79d31d73241 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 3 Jul 2018 18:07:54 +0000 Subject: Use unowned ptr in cpdf_stream_acc Change-Id: Ide081e462c83a5a209a2e6462dd12b298993f36f Reviewed-on: https://pdfium-review.googlesource.com/36850 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_stream_acc.h | 4 ++-- core/fpdfapi/parser/fpdf_parser_decode.cpp | 10 +++++----- core/fpdfapi/parser/fpdf_parser_decode.h | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h index 00bd353fcb..5d18723df5 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.h +++ b/core/fpdfapi/parser/cpdf_stream_acc.h @@ -37,7 +37,7 @@ class CPDF_StreamAcc : public Retainable { return pdfium::make_span(GetData(), GetSize()); } ByteString GetImageDecoder() const { return m_ImageDecoder; } - const CPDF_Dictionary* GetImageParam() const { return m_pImageParam; } + const CPDF_Dictionary* GetImageParam() const { return m_pImageParam.Get(); } std::unique_ptr DetachData(); protected: @@ -49,7 +49,7 @@ class CPDF_StreamAcc : public Retainable { uint32_t m_dwSize = 0; bool m_bNewBuf = false; ByteString m_ImageDecoder; - const CPDF_Dictionary* m_pImageParam = nullptr; + UnownedPtr m_pImageParam; UnownedPtr const m_pStream; uint8_t* m_pSrcData = nullptr; }; diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index 0ca9b4eab2..82d84ab705 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -339,7 +339,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, uint8_t** dest_buf, uint32_t* dest_size, ByteString* ImageEncoding, - const CPDF_Dictionary** pImageParms) { + UnownedPtr* pImageParams) { const CPDF_Object* pDecoder = pDict ? pDict->GetDirectObjectFor("Filter") : nullptr; if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName())) @@ -377,7 +377,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, *ImageEncoding = "FlateDecode"; *dest_buf = last_buf; *dest_size = last_size; - *pImageParms = pParam; + *pImageParams = pParam; return true; } offset = FPDFAPI_FlateOrLZWDecode(false, last_buf, last_size, pParam, @@ -394,7 +394,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, *ImageEncoding = "RunLengthDecode"; *dest_buf = last_buf; *dest_size = last_size; - *pImageParms = pParam; + *pImageParams = pParam; return true; } offset = RunLengthDecode(last_buf, last_size, &new_buf, &new_size); @@ -405,7 +405,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, else if (decoder == "CCF") decoder = "CCITTFaxDecode"; *ImageEncoding = std::move(decoder); - *pImageParms = pParam; + *pImageParams = pParam; *dest_buf = last_buf; *dest_size = last_size; return true; @@ -420,7 +420,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, last_size = new_size; } ImageEncoding->clear(); - *pImageParms = nullptr; + *pImageParams = nullptr; *dest_buf = last_buf; *dest_size = last_size; return true; diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h index c0f636a231..328fd474c6 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.h +++ b/core/fpdfapi/parser/fpdf_parser_decode.h @@ -10,6 +10,7 @@ #include #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/unowned_ptr.h" class CCodec_ScanlineDecoder; class CPDF_Dictionary; @@ -80,6 +81,6 @@ bool PDF_DataDecode(const uint8_t* src_buf, uint8_t** dest_buf, uint32_t* dest_size, ByteString* ImageEncoding, - const CPDF_Dictionary** pImageParms); + UnownedPtr* pImageParms); #endif // CORE_FPDFAPI_PARSER_FPDF_PARSER_DECODE_H_ -- cgit v1.2.3