ICU-22479 Limit the collator_compare_fuzzer

Test only first 4K bytes of data, which means compare two
UnicodeString each with 1024 Unicodes at most.

Avoid finding timeout issue due to large amount of data.
This commit is contained in:
Frank Tang 2023-09-05 11:30:39 -07:00 committed by Frank Yung-Fong Tang
parent 21f74b3698
commit fab5faa3aa

View file

@ -33,6 +33,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
icu::Collator::ECollationStrength strength = kStrength[rnd16 % kStrength.size()];
const icu::Locale& locale = GetRandomLocale(rnd16 / kStrength.size());
// Limit the comparison size to 4096 to avoid unnecessary timeout
if (size > 4096) {
size = 4096;
}
std::unique_ptr<char16_t> compbuff1(new char16_t[size/4]);
std::memcpy(compbuff1.get(), data, (size/4)*2);
data = data + size/2;