OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 |
| 3 // Fuzzer for NumberFormat::parse. |
| 4 |
| 5 #include <stddef.h> |
| 6 #include <stdint.h> |
| 7 #include <memory> |
| 8 #include "third_party/icu/fuzzers/fuzzer_utils.h" |
| 9 #include "third_party/icu/source/i18n/unicode/numfmt.h" |
| 10 |
| 11 IcuEnvironment* env = new IcuEnvironment(); |
| 12 |
| 13 // Entry point for LibFuzzer. |
| 14 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 15 UErrorCode status = U_ZERO_ERROR; |
| 16 |
| 17 auto rng = CreateRng(data, size); |
| 18 const icu::Locale& locale = GetRandomLocale(&rng); |
| 19 |
| 20 std::unique_ptr<icu::NumberFormat> fmt( |
| 21 icu::NumberFormat::createInstance(locale, status)); |
| 22 if (U_FAILURE(status)) return 0; |
| 23 |
| 24 icu::UnicodeString str(reinterpret_cast<const char*>(data), size); |
| 25 icu::Formattable result; |
| 26 fmt->parse(str, result, status); |
| 27 |
| 28 return 0; |
| 29 } |
OLD | NEW |