summaryrefslogtreecommitdiff
path: root/xfa/fgas/font
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-23 23:47:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-23 23:47:03 +0000
commitc1dde5d9b3da2af6e6f81df09ed41ab9c34bbde4 (patch)
tree74a361473c5f8b3044ab3f17e72f784edb72db4b /xfa/fgas/font
parenta41801ee0e7c0d76feca2dfe20103d8b82391026 (diff)
downloadpdfium-c1dde5d9b3da2af6e6f81df09ed41ab9c34bbde4.tar.xz
Pass unique_ptr<> to CFX_MemoryStream constructor
Proves we own the memory that the class will eventually free. Change-Id: Ie9523da8db738e7478a1c73e3e1a6b24aed38442 Reviewed-on: https://pdfium-review.googlesource.com/41290 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fgas/font')
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index f6b168c89d..d0a6127bbc 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -626,10 +626,11 @@ RetainPtr<IFX_SeekableReadStream> CFGAS_FontMgr::CreateFontStream(
if (dwFileSize == 0)
return nullptr;
- uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1);
- dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize);
-
- return pdfium::MakeRetain<CFX_MemoryStream>(pBuffer, dwFileSize);
+ std::unique_ptr<uint8_t, FxFreeDeleter> pBuffer(
+ FX_Alloc(uint8_t, dwFileSize + 1));
+ dwFileSize =
+ pSystemFontInfo->GetFontData(hFont, 0, pBuffer.get(), dwFileSize);
+ return pdfium::MakeRetain<CFX_MemoryStream>(std::move(pBuffer), dwFileSize);
}
RetainPtr<IFX_SeekableReadStream> CFGAS_FontMgr::CreateFontStream(