| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "third_party/hunspell/src/hunspell/hunspell.hxx" | 9 #include "third_party/hunspell/src/hunspell/hunspell.hxx" |
| 10 #include "third_party/hunspell/fuzz/hunspell_fuzzer_dictionary.h" | 10 #include "third_party/hunspell/fuzz/hunspell_fuzzer_hunspell_dictionary.h" |
| 11 | 11 |
| 12 // Entry point for LibFuzzer. | 12 // Entry point for LibFuzzer. |
| 13 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 13 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 14 if (!size) | 14 if (!size) |
| 15 return 0; | 15 return 0; |
| 16 | 16 |
| 17 static Hunspell* hunspell = new Hunspell( | 17 static Hunspell* hunspell = new Hunspell(kHunspellDictionary, |
| 18 reinterpret_cast<const unsigned char*>(kHunspellDictionary), | 18 sizeof(kHunspellDictionary)); |
| 19 sizeof(kHunspellDictionary)); | |
| 20 | 19 |
| 21 std::string data_string(reinterpret_cast<const char*>(data), size); | 20 std::string data_string(reinterpret_cast<const char*>(data), size); |
| 22 hunspell->spell(data_string.c_str()); | 21 hunspell->spell(data_string.c_str()); |
| 23 | 22 |
| 24 char** suggestions = nullptr; | 23 char** suggestions = nullptr; |
| 25 int suggetion_length = hunspell->suggest(&suggestions, data_string.c_str()); | 24 int suggetion_length = hunspell->suggest(&suggestions, data_string.c_str()); |
| 26 hunspell->free_list(&suggestions, suggetion_length); | 25 hunspell->free_list(&suggestions, suggetion_length); |
| 27 | 26 |
| 28 return 0; | 27 return 0; |
| 29 } | 28 } |
| OLD | NEW |