Skip to content

Commit

Permalink
ICU-22516 Return error while the style is invalid
Browse files Browse the repository at this point in the history
To avoid later unknown address in icu_74::UnicodeString::copyFrom
  • Loading branch information
FrankYFTang committed Sep 25, 2023
1 parent 6d1999f commit c1475f4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions icu4c/source/i18n/reldatefmt.cpp
Expand Up @@ -805,6 +805,10 @@ RelativeDateTimeFormatter::RelativeDateTimeFormatter(
if (U_FAILURE(status)) {
return;
}
if (styl < 0 || UDAT_STYLE_COUNT <= styl) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
if ((capitalizationContext >> 8) != UDISPCTX_TYPE_CAPITALIZATION) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
Expand Down

0 comments on commit c1475f4

Please sign in to comment.