1 // © 2019 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 4 #include <cstring> 5 6 #include "fuzzer_utils.h" 7 #include "unicode/coll.h" 8 #include "unicode/localpointer.h" 9 #include "unicode/locid.h" 10 #include "unicode/tblcoll.h" 11 12 IcuEnvironment* env = new IcuEnvironment(); 13 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)14extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 15 UErrorCode status = U_ZERO_ERROR; 16 if (size > 2000) { 17 // Limit the effective test data to only 2000 bytes to avoid meaningless 18 // timeout. 19 size = 2000; 20 } 21 22 size_t unistr_size = size/2; 23 std::unique_ptr<char16_t[]> fuzzbuff(new char16_t[unistr_size]); 24 std::memcpy(fuzzbuff.get(), data, unistr_size * 2); 25 icu::UnicodeString fuzzstr(false, fuzzbuff.get(), unistr_size); 26 27 icu::LocalPointer<icu::RuleBasedCollator> col1( 28 new icu::RuleBasedCollator(fuzzstr, status)); 29 30 return 0; 31 } 32