From 3f054adaf3ca34d55338e56773088bd589600583 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Thu, 4 Jan 2024 15:19:43 -0800 Subject: [PATCH] ICU-22549 Fix fuzzer to call Locale with null-terminiate string --- icu4c/source/test/fuzzer/plurrule_fuzzer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/icu4c/source/test/fuzzer/plurrule_fuzzer.cpp b/icu4c/source/test/fuzzer/plurrule_fuzzer.cpp index 3ff0cb1730c..634d505aede 100644 --- a/icu4c/source/test/fuzzer/plurrule_fuzzer.cpp +++ b/icu4c/source/test/fuzzer/plurrule_fuzzer.cpp @@ -74,7 +74,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { status = U_ZERO_ERROR; TestPluralRulesWithLocale(locale, number, dbl, type, status); - icu::Locale locale2 = icu::Locale(fuzzData.data()); + std::string str(fuzzData.data(), fuzzData.size()); // ensure null-terminate + // by std::string c_str + icu::Locale locale2(str.c_str()); status = U_ZERO_ERROR; TestPluralRulesWithLocale(locale2, number, dbl, type, status);