From 4412f3d87441c135ef56420f18d9229fbe247c3e Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 11 Dec 2017 22:10:29 +0000 Subject: Slightly simplify CPDF_StreamAcc::LoadAllData(). Also initialize members in the header. Change-Id: Ic1cda7f9ef4c69e26604c706678aed24bf4e8ee3 Reviewed-on: https://pdfium-review.googlesource.com/20790 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- core/fpdfapi/parser/cpdf_stream_acc.cpp | 18 +++++++----------- core/fpdfapi/parser/cpdf_stream_acc.h | 10 +++++----- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp index b539117bd3..5792a80d14 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.cpp +++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp @@ -9,12 +9,7 @@ #include "core/fpdfapi/parser/fpdf_parser_decode.h" CPDF_StreamAcc::CPDF_StreamAcc(const CPDF_Stream* pStream) - : m_pData(nullptr), - m_dwSize(0), - m_bNewBuf(false), - m_pImageParam(nullptr), - m_pStream(pStream), - m_pSrcData(nullptr) {} + : m_pStream(pStream) {} CPDF_StreamAcc::~CPDF_StreamAcc() { if (m_bNewBuf) @@ -28,7 +23,8 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess, if (!m_pStream) return; - if (m_pStream->IsMemoryBased() && (!m_pStream->HasFilter() || bRawAccess)) { + bool bProcessRawData = bRawAccess || !m_pStream->HasFilter(); + if (bProcessRawData && m_pStream->IsMemoryBased()) { m_dwSize = m_pStream->GetRawSize(); m_pData = m_pStream->GetRawData(); return; @@ -38,14 +34,14 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess, return; uint8_t* pSrcData; - if (!m_pStream->IsMemoryBased()) { + if (m_pStream->IsMemoryBased()) { + pSrcData = m_pStream->GetRawData(); + } else { pSrcData = m_pSrcData = FX_Alloc(uint8_t, dwSrcSize); if (!m_pStream->ReadRawData(0, pSrcData, dwSrcSize)) return; - } else { - pSrcData = m_pStream->GetRawData(); } - if (!m_pStream->HasFilter() || bRawAccess) { + if (bProcessRawData) { m_pData = pSrcData; m_dwSize = dwSrcSize; } else if (!PDF_DataDecode(pSrcData, dwSrcSize, m_pStream->GetDict(), diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h index 6a18c43975..52ac7e2e05 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.h +++ b/core/fpdfapi/parser/cpdf_stream_acc.h @@ -44,13 +44,13 @@ class CPDF_StreamAcc : public Retainable { private: uint8_t* GetDataHelper() const; - uint8_t* m_pData; - uint32_t m_dwSize; - bool m_bNewBuf; + uint8_t* m_pData = nullptr; + uint32_t m_dwSize = 0; + bool m_bNewBuf = false; ByteString m_ImageDecoder; - CPDF_Dictionary* m_pImageParam; + CPDF_Dictionary* m_pImageParam = nullptr; UnownedPtr const m_pStream; - uint8_t* m_pSrcData; + uint8_t* m_pSrcData = nullptr; }; #endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_ACC_H_ -- cgit v1.2.3