summaryrefslogtreecommitdiff
path: root/core/fpdfapi/edit
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-15 16:56:47 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-15 16:56:47 +0000
commit7c39bf7b87f871ccc50b66066c3bfb1883f66010 (patch)
tree57f56441c6e7b136ee0418fcb2dc53d866a780c0 /core/fpdfapi/edit
parent4f5ccaaecd7e524e98b79af6823a9ab6a8753d7f (diff)
downloadpdfium-7c39bf7b87f871ccc50b66066c3bfb1883f66010.tar.xz
Make FlateEncode()'s buffer out parameter a unique_ptr.
Change-Id: I31a5abb3c8dd31826098493f51effbd5afe109d1 Reviewed-on: https://pdfium-review.googlesource.com/c/41856 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/edit')
-rw-r--r--core/fpdfapi/edit/cpdf_flateencoder.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/fpdfapi/edit/cpdf_flateencoder.cpp b/core/fpdfapi/edit/cpdf_flateencoder.cpp
index ba04d7d938..7172bf2d7f 100644
--- a/core/fpdfapi/edit/cpdf_flateencoder.cpp
+++ b/core/fpdfapi/edit/cpdf_flateencoder.cpp
@@ -7,6 +7,7 @@
#include "core/fpdfapi/edit/cpdf_flateencoder.h"
#include <memory>
+#include <utility>
#include "constants/stream_dict_common.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
@@ -40,10 +41,10 @@ CPDF_FlateEncoder::CPDF_FlateEncoder(const CPDF_Stream* pStream,
}
// TODO(thestig): Move to Init() and check return value.
- uint8_t* buffer = nullptr;
+ std::unique_ptr<uint8_t, FxFreeDeleter> buffer;
::FlateEncode(m_pAcc->GetSpan(), &buffer, &m_dwSize);
- m_pData = std::unique_ptr<uint8_t, FxFreeDeleter>(buffer);
+ m_pData = std::move(buffer);
m_pClonedDict = ToDictionary(pStream->GetDict()->Clone());
m_pClonedDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(m_dwSize));
m_pClonedDict->SetNewFor<CPDF_Name>("Filter", "FlateDecode");