Remove |bTakeOver| parameter from CFX_MemoryStream ctor. It is always true now. BUG=pdfium:263 Change-Id: I74fd0091f5815701718e8cd5acc6e7a0de772a85 Reviewed-on: https://pdfium-review.googlesource.com/40031 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_object_stream.cpp b/core/fpdfapi/parser/cpdf_object_stream.cpp index a85cbf1..d6b3d36 100644 --- a/core/fpdfapi/parser/cpdf_object_stream.cpp +++ b/core/fpdfapi/parser/cpdf_object_stream.cpp
@@ -97,8 +97,7 @@ 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 15cde78..b0a0bd9 100644 --- a/core/fxcrt/cfx_memorystream.cpp +++ b/core/fxcrt/cfx_memorystream.cpp
@@ -17,26 +17,16 @@ } // namespace CFX_MemoryStream::CFX_MemoryStream(bool bConsecutive) - : m_nTotalSize(0), - m_nCurSize(0), - m_bConsecutive(bConsecutive), - m_bTakeOver(true) {} + : m_nTotalSize(0), m_nCurSize(0), m_bConsecutive(bConsecutive) {} -CFX_MemoryStream::CFX_MemoryStream(uint8_t* pBuffer, - size_t nSize, - bool bTakeOver) - : m_nTotalSize(nSize), - m_nCurSize(nSize), - m_bConsecutive(true), - m_bTakeOver(bTakeOver) { +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 cd89c62..95f62b6 100644 --- a/core/fxcrt/cfx_memorystream.h +++ b/core/fxcrt/cfx_memorystream.h
@@ -32,7 +32,9 @@ 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 @@ 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_
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index f173bf2..f6b168c 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -179,7 +179,8 @@ // Use a named object to store the returned value of EnumGdiFonts() instead // of using a temporary object. This can prevent use-after-free issues since // pDesc may point to one of std::deque object's elements. - std::deque<FX_FONTDESCRIPTOR> namedFonts = EnumGdiFonts(pszFontFamily, wUnicode); + std::deque<FX_FONTDESCRIPTOR> namedFonts = + EnumGdiFonts(pszFontFamily, wUnicode); params.pwsFamily = nullptr; pDesc = MatchDefaultFont(¶ms, namedFonts); if (!pDesc) @@ -628,7 +629,7 @@ uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); - return pdfium::MakeRetain<CFX_MemoryStream>(pBuffer, dwFileSize, true); + return pdfium::MakeRetain<CFX_MemoryStream>(pBuffer, dwFileSize); } RetainPtr<IFX_SeekableReadStream> CFGAS_FontMgr::CreateFontStream(