diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-12 17:02:40 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-12 17:02:40 +0000 |
commit | 0f567261d33a70860bb3ec3db4cf1185df1a9a54 (patch) | |
tree | 223af177a043b42a2ba3913fcb0068f1b054a0fc /core/fpdfapi/parser/cpdf_stream_acc.cpp | |
parent | 94f3ca931552ba76d1b216020633829e1a07b212 (diff) | |
download | pdfium-0f567261d33a70860bb3ec3db4cf1185df1a9a54.tar.xz |
Make PDF_DataDecode()'s buffer out parameter a std::unique_ptr.
Change-Id: Id8f7473c590ef94799d0dd29f5de790a453c86f6
Reviewed-on: https://pdfium-review.googlesource.com/c/42603
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_stream_acc.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_stream_acc.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp index c87e404186..6516a2ff2c 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.cpp +++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp @@ -115,7 +115,7 @@ void CPDF_StreamAcc::ProcessFilteredData(uint32_t estimated_size, pSrcData = std::move(pTempSrcData); } - uint8_t* pDecodedData = nullptr; + std::unique_ptr<uint8_t, FxFreeDeleter> pDecodedData; uint32_t dwDecodedSize = 0; if (!PDF_DataDecode({pSrcData.Get(), dwSrcSize}, m_pStream->GetDict(), estimated_size, bImageAcc, &pDecodedData, &dwDecodedSize, @@ -125,16 +125,13 @@ void CPDF_StreamAcc::ProcessFilteredData(uint32_t estimated_size, return; } - if (!pDecodedData) - return; - - if (pDecodedData == pSrcData.Get()) { + if (pDecodedData) { + ASSERT(pDecodedData.get() != pSrcData.Get()); + m_pData = std::move(pDecodedData); + m_dwSize = dwDecodedSize; + } else { m_pData = std::move(pSrcData); m_dwSize = dwSrcSize; - } else { - std::unique_ptr<uint8_t, FxFreeDeleter> p(pDecodedData); - m_pData = std::move(p); - m_dwSize = dwDecodedSize; } } |