Skip to content

Commit

Permalink
ICU-22818 Fix memory leak during error in messageformat2_data_model.cpp
Browse files Browse the repository at this point in the history
See #3077
  • Loading branch information
FrankYFTang committed Aug 6, 2024
1 parent a22dc93 commit 1eb0ed2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions icu4c/source/i18n/messageformat2_data_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,13 +1091,13 @@ MFDataModel::MFDataModel(const MFDataModel::Builder& builder, UErrorCode& errorC
U_ASSERT(builder.selectors != nullptr);
int32_t numVariants = builder.variants->size();
int32_t numSelectors = builder.selectors->size();
Variant* variants = copyVectorToArray<Variant>(*builder.variants, errorCode);
Expression* selectors = copyVectorToArray<Expression>(*builder.selectors, errorCode);
LocalArray<Variant> variants(copyVectorToArray<Variant>(*builder.variants, errorCode), errorCode);
LocalArray<Expression> selectors(copyVectorToArray<Expression>(*builder.selectors, errorCode), errorCode);
if (U_FAILURE(errorCode)) {
bogus = true;
return;
}
body.emplace<Matcher>(Matcher(selectors, numSelectors, variants, numVariants));
body.emplace<Matcher>(Matcher(selectors.orphan(), numSelectors, variants.orphan(), numVariants));
}

U_ASSERT(builder.bindings != nullptr);
Expand Down

0 comments on commit 1eb0ed2

Please sign in to comment.