summaryrefslogtreecommitdiff
path: root/testing/libfuzzer/xfa_codec_fuzzer.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-01 12:15:00 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-03-01 20:43:46 +0000
commitb4a261855b34b4c8d938118762ae609a34a3ae99 (patch)
tree7b084e874cbf41eec73a3cec949dc810983cc0cf /testing/libfuzzer/xfa_codec_fuzzer.h
parentfed39cf4a23341cf9cb5a5b432248b4247022282 (diff)
downloadpdfium-b4a261855b34b4c8d938118762ae609a34a3ae99.tar.xz
Create virtual codec APIs so chrome/fuzzers can link separately
The one step to make an actual concrete class is conditionalized in fpdfview and is unconditional in the fuzzer. Also replace the clumsy C-style callbacks with a delegate interface as long as we are making new interfaces. Change-Id: I733a437483ce5e0c34211cfbbda05105336f55b5 Reviewed-on: https://pdfium-review.googlesource.com/2887 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'testing/libfuzzer/xfa_codec_fuzzer.h')
-rw-r--r--testing/libfuzzer/xfa_codec_fuzzer.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/testing/libfuzzer/xfa_codec_fuzzer.h b/testing/libfuzzer/xfa_codec_fuzzer.h
index 8608993396..9a8b23e368 100644
--- a/testing/libfuzzer/xfa_codec_fuzzer.h
+++ b/testing/libfuzzer/xfa_codec_fuzzer.h
@@ -7,16 +7,26 @@
#include <memory>
+#include "core/fxcodec/codec/ccodec_bmpmodule.h"
+#include "core/fxcodec/codec/ccodec_gifmodule.h"
+#include "core/fxcodec/codec/ccodec_pngmodule.h"
#include "core/fxcodec/codec/ccodec_progressivedecoder.h"
+#include "core/fxcodec/codec/ccodec_tiffmodule.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/fx_stream.h"
+#include "third_party/base/ptr_util.h"
class XFACodecFuzzer {
public:
static int Fuzz(const uint8_t* data, size_t size, FXCODEC_IMAGE_TYPE type) {
- std::unique_ptr<CCodec_ModuleMgr> mgr(new CCodec_ModuleMgr());
- std::unique_ptr<CCodec_ProgressiveDecoder> decoder(
- mgr->CreateProgressiveDecoder());
+ auto mgr = pdfium::MakeUnique<CCodec_ModuleMgr>();
+ mgr->SetBmpModule(pdfium::MakeUnique<CCodec_BmpModule>());
+ mgr->SetGifModule(pdfium::MakeUnique<CCodec_GifModule>());
+ mgr->SetPngModule(pdfium::MakeUnique<CCodec_PngModule>());
+ mgr->SetTiffModule(pdfium::MakeUnique<CCodec_TiffModule>());
+
+ std::unique_ptr<CCodec_ProgressiveDecoder> decoder =
+ mgr->CreateProgressiveDecoder();
CFX_RetainPtr<Reader> source(new Reader(data, size));
FXCODEC_STATUS status = decoder->LoadImageInfo(source, type, nullptr, true);
if (status != FXCODEC_STATUS_FRAME_READY)