-
-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14ca2b0
commit d082de5
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// © 2023 and later: Unicode, Inc. and others. | ||
// License & terms of use: http://www.unicode.org/copyright.html | ||
|
||
// Fuzzer for ICU Calendar. | ||
|
||
#include <cstring> | ||
|
||
#include "fuzzer_utils.h" | ||
|
||
#include "unicode/datefmt.h" | ||
#include "unicode/locid.h" | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | ||
uint16_t rnd; | ||
UDate date; | ||
icu::DateFormat::EStyle dateStyle; | ||
icu::DateFormat::EStyle timeStyle; | ||
if (size < sizeof(rnd) + sizeof(date) + sizeof(dateStyle) + sizeof(timeStyle)) return 0; | ||
icu::StringPiece fuzzData(reinterpret_cast<const char *>(data), size); | ||
|
||
std::memcpy(&rnd, fuzzData.data(), sizeof(rnd)); | ||
fuzzData.remove_prefix(sizeof(rnd)); | ||
icu::Locale locale = GetRandomLocale(rnd); | ||
|
||
std::memcpy(&dateStyle, fuzzData.data(), sizeof(dateStyle)); | ||
fuzzData.remove_prefix(sizeof(dateStyle)); | ||
std::memcpy(&timeStyle, fuzzData.data(), sizeof(timeStyle)); | ||
fuzzData.remove_prefix(sizeof(timeStyle)); | ||
std::memcpy(&date, fuzzData.data(), sizeof(date)); | ||
fuzzData.remove_prefix(sizeof(date)); | ||
|
||
std::unique_ptr<icu::DateFormat> df( | ||
icu::DateFormat::createDateTimeInstance(dateStyle, timeStyle, locale)); | ||
icu::UnicodeString appendTo; | ||
df->format(date, appendTo); | ||
icu::UnicodeString skeleton = icu::UnicodeString::fromUTF8(fuzzData); | ||
|
||
UErrorCode status = U_ZERO_ERROR; | ||
appendTo.remove(); | ||
df.reset(icu::DateFormat::createInstanceForSkeleton(skeleton, status)); | ||
if (U_SUCCESS(status)) { | ||
df->format(date, appendTo); | ||
} | ||
|
||
status = U_ZERO_ERROR; | ||
appendTo.remove(); | ||
df.reset(icu::DateFormat::createInstanceForSkeleton(skeleton, locale, status)); | ||
if (U_SUCCESS(status)) { | ||
df->format(date, appendTo); | ||
} | ||
return EXIT_SUCCESS; | ||
} |
d082de5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
2
.TestCharsetDecoderICU
6.033186941381195
ns/iter2.7950331629283
ns/iter2.16
This comment was automatically generated by workflow using github-action-benchmark.