summaryrefslogtreecommitdiff
path: root/core/fxcodec
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/fxcodec
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/fxcodec')
-rw-r--r--core/fxcodec/codec/ccodec_flatemodule.cpp13
-rw-r--r--core/fxcodec/codec/ccodec_flatemodule.h2
2 files changed, 8 insertions, 7 deletions
diff --git a/core/fxcodec/codec/ccodec_flatemodule.cpp b/core/fxcodec/codec/ccodec_flatemodule.cpp
index f35b9581be..f447ec567f 100644
--- a/core/fxcodec/codec/ccodec_flatemodule.cpp
+++ b/core/fxcodec/codec/ccodec_flatemodule.cpp
@@ -834,14 +834,15 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(
return ret ? offset : FX_INVALID_OFFSET;
}
-bool CCodec_FlateModule::Encode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t** dest_buf,
- uint32_t* dest_size) {
+bool CCodec_FlateModule::Encode(
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ std::unique_ptr<uint8_t, FxFreeDeleter>* dest_buf,
+ uint32_t* dest_size) {
*dest_size = src_size + src_size / 1000 + 12;
- *dest_buf = FX_Alloc(uint8_t, *dest_size);
+ dest_buf->reset(FX_Alloc(uint8_t, *dest_size));
unsigned long temp_size = *dest_size;
- if (!FlateCompress(*dest_buf, &temp_size, src_buf, src_size))
+ if (!FlateCompress(dest_buf->get(), &temp_size, src_buf, src_size))
return false;
*dest_size = (uint32_t)temp_size;
diff --git a/core/fxcodec/codec/ccodec_flatemodule.h b/core/fxcodec/codec/ccodec_flatemodule.h
index 591d13d42e..d58c1847ce 100644
--- a/core/fxcodec/codec/ccodec_flatemodule.h
+++ b/core/fxcodec/codec/ccodec_flatemodule.h
@@ -41,7 +41,7 @@ class CCodec_FlateModule {
bool Encode(const uint8_t* src_buf,
uint32_t src_size,
- uint8_t** dest_buf,
+ std::unique_ptr<uint8_t, FxFreeDeleter>* dest_buf,
uint32_t* dest_size);
};