From ea8faee2778034963576a7e863ec198c30931df3 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 14 Jan 2018 01:26:57 +0100 Subject: [PATCH] Refactored the code. --- Magick++/fuzz/main.cc | 60 +++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/Magick++/fuzz/main.cc b/Magick++/fuzz/main.cc index 293c20de2..edd4a59bd 100644 --- a/Magick++/fuzz/main.cc +++ b/Magick++/fuzz/main.cc @@ -15,46 +15,44 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); class FuzzingDebugger { public: - bool load(wstring fileName); - void start(); + bool load(wstring fileName) + { + ifstream + file; -private: - char * _data; - size_t _size; -}; + streampos + size; -bool FuzzingDebugger::load(wstring fileName) -{ - ifstream - file; + file = ifstream(fileName, ios::in | ios::binary | ios::ate); + if (!file.is_open()) + return(false); - streampos - size; + size = file.tellg(); + _size = size; + _data = new char[_size]; + file.seekg(0, ios::beg); + file.read(_data, size); + file.close(); - file = ifstream(fileName, ios::in | ios::binary | ios::ate); - if (!file.is_open()) - return(false); + encoderFormat.set(wstring(PathFindExtension(fileName.c_str()))); - size = file.tellg(); - _size = size; - _data = new char[_size]; - file.seekg(0, ios::beg); - file.read(_data, size); - file.close(); + return(true); + } - encoderFormat.set(wstring(PathFindExtension(fileName.c_str()))); + void start() + { + const uint8_t + *data; - return(true); -} + data = reinterpret_cast(_data); + LLVMFuzzerTestOneInput(data, _size); + } -void FuzzingDebugger::start() -{ - const uint8_t - *data; - data = reinterpret_cast(_data); - LLVMFuzzerTestOneInput(data, _size); -} +private: + char * _data; + size_t _size; +}; int wmain(int argc, wchar_t *argv[]) { -- 2.40.0