summaryrefslogtreecommitdiff
path: root/testing/libfuzzer
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-30 16:12:02 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-30 20:26:02 +0000
commit0bb1333a9eff1190ddd68f34c71d6a779c69dfef (patch)
tree5a46946c4852f147309e2b1389e6f42d6553abf7 /testing/libfuzzer
parent908c848202ef137e98d96f82a4eadfae551403b7 (diff)
downloadpdfium-0bb1333a9eff1190ddd68f34c71d6a779c69dfef.tar.xz
Add some calls to MakeUnique
This CL replaces some new's with pdfium::MakeUnique. Change-Id: I50faf3ed55e7730b094c14a7989a9dd51cf33cbb Reviewed-on: https://pdfium-review.googlesource.com/3430 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'testing/libfuzzer')
-rw-r--r--testing/libfuzzer/pdf_codec_jbig2_fuzzer.cc3
-rw-r--r--testing/libfuzzer/pdf_jpx_fuzzer.cc9
2 files changed, 5 insertions, 7 deletions
diff --git a/testing/libfuzzer/pdf_codec_jbig2_fuzzer.cc b/testing/libfuzzer/pdf_codec_jbig2_fuzzer.cc
index 162a0bf772..e86ebeb242 100644
--- a/testing/libfuzzer/pdf_codec_jbig2_fuzzer.cc
+++ b/testing/libfuzzer/pdf_codec_jbig2_fuzzer.cc
@@ -10,6 +10,7 @@
#include "core/fxcodec/codec/ccodec_jbig2module.h"
#include "core/fxcodec/jbig2/JBig2_Context.h"
#include "core/fxge/fx_dib.h"
+#include "third_party/base/ptr_util.h"
static uint32_t GetInteger(const uint8_t* data) {
return data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;
@@ -29,7 +30,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (!bitmap->Create(width, height, FXDIB_1bppRgb))
return 0;
- std::unique_ptr<CPDF_Object> stream(new CPDF_Stream);
+ auto stream = pdfium::MakeUnique<CPDF_Stream>();
stream->AsStream()->SetData(data, size);
CPDF_StreamAcc src_stream;
src_stream.LoadAllData(stream->AsStream(), true);
diff --git a/testing/libfuzzer/pdf_jpx_fuzzer.cc b/testing/libfuzzer/pdf_jpx_fuzzer.cc
index 92ba210be3..5ac31486f1 100644
--- a/testing/libfuzzer/pdf_jpx_fuzzer.cc
+++ b/testing/libfuzzer/pdf_jpx_fuzzer.cc
@@ -6,18 +6,15 @@
#include <memory>
#include <vector>
+#include "core/fxcodec/codec/cjpx_decoder.h"
#include "core/fxcodec/codec/codec_int.h"
#include "core/fxge/fx_dib.h"
CCodec_JpxModule g_module;
-struct DecoderDeleter {
- void operator()(CJPX_Decoder* decoder) { g_module.DestroyDecoder(decoder); }
-};
-
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- std::unique_ptr<CJPX_Decoder, DecoderDeleter> decoder(
- g_module.CreateDecoder(data, size, nullptr));
+ std::unique_ptr<CJPX_Decoder> decoder =
+ g_module.CreateDecoder(data, size, nullptr);
if (!decoder)
return 0;