Skip to content

Commit

Permalink
ICU-22884 Fix assertion and Heap-use-after-free
Browse files Browse the repository at this point in the history
Issue in icu_76::message2::MessageFormatter::~MessageFormatter
  • Loading branch information
FrankYFTang committed Sep 12, 2024
1 parent 923d02f commit fd8a552
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_data_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ OptionMap::OptionMap(const UVector& opts, UErrorCode& status) : len(opts.size())

OptionMap::OptionMap(const OptionMap& other) : len(other.len) {
U_ASSERT(!other.bogus);
if (len == 0) {
bogus = false;
return;
}
UErrorCode localErrorCode = U_ZERO_ERROR;
Option* result = copyArray(other.options.getAlias(), len, localErrorCode);
if (U_FAILURE(localErrorCode)) {
Expand Down
1 change: 1 addition & 0 deletions icu4c/source/i18n/messageformat2_formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ namespace message2 {
void MessageFormatter::cleanup() noexcept {
if (errors != nullptr) {
delete errors;
errors = nullptr;
}
}

Expand Down

0 comments on commit fd8a552

Please sign in to comment.