Chromium Code Reviews| Index: third_party/hunspell/fuzz/hunspell_fuzzer.cc |
| diff --git a/third_party/hunspell/fuzz/hunspell_fuzzer.cc b/third_party/hunspell/fuzz/hunspell_fuzzer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..143a7806c63c72e4a0c6e948346bcab3cb8f10f2 |
| --- /dev/null |
| +++ b/third_party/hunspell/fuzz/hunspell_fuzzer.cc |
| @@ -0,0 +1,31 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <stddef.h> |
| +#include <stdint.h> |
| +#include <string> |
| + |
| +#include "third_party/hunspell/src/hunspell/hunspell.hxx" |
| + |
|
please use gerrit instead
2016/06/03 17:52:45
No newline here.
mmoroz
2016/06/03 18:00:03
Done.
|
| +#include "third_party/hunspell/fuzz/hunspell_fuzzer_dictionary.h" |
| + |
|
please use gerrit instead
2016/06/03 17:52:45
Only 1 newline here.
mmoroz
2016/06/03 18:00:03
Done.
|
| + |
| +// Entry point for LibFuzzer. |
| +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| + if (!size) |
| + return 0; |
| + |
| + static Hunspell* hunspell = new Hunspell( |
| + reinterpret_cast<const unsigned char*>(kHunspellDictionary), |
| + sizeof(kHunspellDictionary)); |
| + |
| + std::string data_string(reinterpret_cast<const char*>(data), size); |
| + hunspell->spell(data_string.c_str()); |
| + |
| + char** suggestions = nullptr; |
| + int suggetion_length = hunspell->suggest(&suggestions, data_string.c_str()); |
| + hunspell->free_list(&suggestions, suggetion_length); |
| + |
| + return 0; |
| +} |