ICU-22884 Fix assertion and Heap-use-after-free

Issue in icu_76::message2::MessageFormatter::~MessageFormatter
This commit is contained in:
Frank Tang 2024-09-11 15:12:54 -07:00 committed by Frank Yung-Fong Tang
parent 923d02f8d1
commit fd8a552527
2 changed files with 5 additions and 0 deletions

View file

@ -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)) {

View file

@ -150,6 +150,7 @@ namespace message2 {
void MessageFormatter::cleanup() noexcept {
if (errors != nullptr) {
delete errors;
errors = nullptr;
}
}