From 231320c4acdcc2404e495ace6cb14f33f591b629 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 17 Sep 2018 18:56:38 +0000 Subject: Remove CPDF_StreamAcc::m_pSrcData. It just ends up being a nullptr, so it is not useful. Change-Id: I52fcbb261c4bb0bc024e1856da95028431d577c1 Reviewed-on: https://pdfium-review.googlesource.com/42591 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- core/fpdfapi/parser/cpdf_stream_acc.cpp | 12 +++++------- core/fpdfapi/parser/cpdf_stream_acc.h | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp index 78bcb57e0b..4614dae710 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.cpp +++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp @@ -14,7 +14,6 @@ CPDF_StreamAcc::CPDF_StreamAcc(const CPDF_Stream* pStream) CPDF_StreamAcc::~CPDF_StreamAcc() { if (m_bNewBuf) FX_Free(m_pData); - FX_Free(m_pSrcData); } void CPDF_StreamAcc::LoadAllData(bool bRawAccess, @@ -42,12 +41,12 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess, if (m_pStream->IsMemoryBased()) { pSrcData = m_pStream->GetInMemoryRawData(); } else { - pSrcData = m_pSrcData = FX_Alloc(uint8_t, dwSrcSize); - if (!m_pStream->ReadRawData(0, pSrcData, dwSrcSize)) { - FX_Free(pSrcData); - pSrcData = m_pSrcData = nullptr; + std::unique_ptr pTempSrcData( + FX_Alloc(uint8_t, dwSrcSize)); + if (!m_pStream->ReadRawData(0, pTempSrcData.get(), dwSrcSize)) return; - } + + pSrcData = pTempSrcData.release(); } if (bProcessRawData) { m_pData = pSrcData; @@ -60,7 +59,6 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess, } if (pSrcData != m_pStream->GetInMemoryRawData() && pSrcData != m_pData) FX_Free(pSrcData); - m_pSrcData = nullptr; m_bNewBuf = m_pData != m_pStream->GetInMemoryRawData(); } diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h index ddbdc6ae0f..6ecfece5ab 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.h +++ b/core/fpdfapi/parser/cpdf_stream_acc.h @@ -53,7 +53,6 @@ class CPDF_StreamAcc final : public Retainable { ByteString m_ImageDecoder; UnownedPtr m_pImageParam; UnownedPtr const m_pStream; - uint8_t* m_pSrcData = nullptr; }; #endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_ACC_H_ -- cgit v1.2.3