diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/parser/cpdf_object_stream.cpp | 3 | ||||
-rw-r--r-- | core/fxcrt/cfx_memorystream.cpp | 22 | ||||
-rw-r--r-- | core/fxcrt/cfx_memorystream.h | 5 |
3 files changed, 10 insertions, 20 deletions
diff --git a/core/fpdfapi/parser/cpdf_object_stream.cpp b/core/fpdfapi/parser/cpdf_object_stream.cpp index a85cbf1ffa..d6b3d365f6 100644 --- a/core/fpdfapi/parser/cpdf_object_stream.cpp +++ b/core/fpdfapi/parser/cpdf_object_stream.cpp @@ -97,8 +97,7 @@ void CPDF_ObjectStream::Init(const CPDF_Stream* stream) { stream_acc->LoadAllDataFiltered(); const uint32_t data_size = stream_acc->GetSize(); data_stream_ = pdfium::MakeRetain<CFX_MemoryStream>( - stream_acc->DetachData().release(), static_cast<size_t>(data_size), - true); + stream_acc->DetachData().release(), data_size); } CPDF_SyntaxParser syntax(data_stream_); diff --git a/core/fxcrt/cfx_memorystream.cpp b/core/fxcrt/cfx_memorystream.cpp index 15cde78f42..b0a0bd91d1 100644 --- a/core/fxcrt/cfx_memorystream.cpp +++ b/core/fxcrt/cfx_memorystream.cpp @@ -17,26 +17,16 @@ constexpr size_t kBlockSize = 64 * 1024; } // namespace CFX_MemoryStream::CFX_MemoryStream(bool bConsecutive) - : m_nTotalSize(0), - m_nCurSize(0), - m_bConsecutive(bConsecutive), - m_bTakeOver(true) {} - -CFX_MemoryStream::CFX_MemoryStream(uint8_t* pBuffer, - size_t nSize, - bool bTakeOver) - : m_nTotalSize(nSize), - m_nCurSize(nSize), - m_bConsecutive(true), - m_bTakeOver(bTakeOver) { + : m_nTotalSize(0), m_nCurSize(0), m_bConsecutive(bConsecutive) {} + +CFX_MemoryStream::CFX_MemoryStream(uint8_t* pBuffer, size_t nSize) + : m_nTotalSize(nSize), m_nCurSize(nSize), m_bConsecutive(true) { m_Blocks.push_back(pBuffer); } CFX_MemoryStream::~CFX_MemoryStream() { - if (m_bTakeOver) { - for (uint8_t* pBlock : m_Blocks) - FX_Free(pBlock); - } + for (uint8_t* pBlock : m_Blocks) + FX_Free(pBlock); } FX_FILESIZE CFX_MemoryStream::GetSize() { diff --git a/core/fxcrt/cfx_memorystream.h b/core/fxcrt/cfx_memorystream.h index cd89c629fc..95f62b6a2c 100644 --- a/core/fxcrt/cfx_memorystream.h +++ b/core/fxcrt/cfx_memorystream.h @@ -32,7 +32,9 @@ class CFX_MemoryStream : public IFX_SeekableStream { private: explicit CFX_MemoryStream(bool bConsecutive); - CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, bool bTakeOver); + + // Takes ownership of |pBuffer|. + CFX_MemoryStream(uint8_t* pBuffer, size_t nSize); ~CFX_MemoryStream() override; bool ExpandBlocks(size_t size); @@ -42,7 +44,6 @@ class CFX_MemoryStream : public IFX_SeekableStream { size_t m_nCurSize; size_t m_nCurPos = 0; const bool m_bConsecutive; - const bool m_bTakeOver; // Owns the data in |m_Blocks|. }; #endif // CORE_FXCRT_CFX_MEMORYSTREAM_H_ |