Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <stddef.h> | |
| 6 #include <stdint.h> | |
| 7 | |
| 8 #include "third_party/hunspell/src/hunspell/hunspell.hxx" | |
| 9 | |
| 10 #include <string> | |
|
please use gerrit instead
2016/06/01 17:09:17
This include should be next to <stdint.h>
mmoroz
2016/06/02 10:54:36
Done.
| |
| 11 | |
| 12 #include "hunspell_fuzzer_dictionary.h" | |
|
please use gerrit instead
2016/06/01 17:09:17
All includes should have full path.
#include "thi
mmoroz
2016/06/02 10:54:36
Done.
| |
| 13 | |
| 14 static Hunspell *CreateHunspell() { | |
|
please use gerrit instead
2016/06/01 17:09:17
This function is used only once. You should inline
mmoroz
2016/06/02 10:54:36
We disable inlining for fuzzers, so I guess it won
please use gerrit instead
2016/06/02 16:03:50
Sorry, when I said "inline", I meant this:
static
mmoroz
2016/06/03 13:07:37
Done.
| |
| 15 return new Hunspell( | |
| 16 reinterpret_cast<const unsigned char*>(kHunspell_Dictionary), | |
| 17 sizeof(kHunspell_Dictionary)); | |
| 18 } | |
| 19 | |
| 20 // Entry point for LibFuzzer. | |
| 21 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | |
| 22 if (!size) | |
| 23 return 0; | |
| 24 | |
| 25 static Hunspell *hunspell = CreateHunspell(); | |
| 26 std::string data_string(reinterpret_cast<const char*>(data), size); | |
| 27 hunspell->spell(data_string.c_str()); | |
| 28 | |
| 29 char** suggestions = nullptr; | |
| 30 int suggetion_length = hunspell->suggest(&suggestions, data_string.c_str()); | |
| 31 hunspell->free_list(&suggestions, suggetion_length); | |
| 32 | |
| 33 return 0; | |
| 34 } | |
| OLD | NEW |