summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Chang <vichang@google.com>2024-05-15 13:34:32 +0100
committerVictor Chang <vichang@google.com>2024-05-15 13:38:37 +0100
commit11098a983d9e0af1d4859d440fa7ab74960207fe (patch)
tree52461592fb3f1ccf728d94ce85942a846ee304be
parent355a301ffec53fc1f15ea5ed33f0dcb50815a68c (diff)
downloadicu-main.tar.gz
Cherry-pick: ICU-22753 Fix read-after-move in MF2HEADmastermain
Upstream bug: https://unicode-org.atlassian.net/browse/ICU-22753 Upstream commit: https://github.com/unicode-org/icu/commit/e6ac2a292fac59032eb3ba11847a43bd5837c30c In StaticErrors::addError() and DynamicErrors::addError(), don't read from `e` after moving out of it. Bug: 320769332 Test: m CtsIcu4cTestCases Change-Id: I67826cf07419f31e0b7c55765de774f1f5f27c23
-rw-r--r--icu4c/source/i18n/messageformat2_errors.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/icu4c/source/i18n/messageformat2_errors.cpp b/icu4c/source/i18n/messageformat2_errors.cpp
index 48fa17a79..cbb9e1497 100644
--- a/icu4c/source/i18n/messageformat2_errors.cpp
+++ b/icu4c/source/i18n/messageformat2_errors.cpp
@@ -189,10 +189,12 @@ namespace message2 {
void StaticErrors::addError(StaticError&& e, UErrorCode& status) {
CHECK_ERROR(status);
+ StaticErrorType type = e.type;
+
void* errorP = static_cast<void*>(create<StaticError>(std::move(e), status));
U_ASSERT(syntaxAndDataModelErrors.isValid());
- switch (e.type) {
+ switch (type) {
case StaticErrorType::SyntaxError: {
syntaxError = true;
break;
@@ -229,10 +231,12 @@ namespace message2 {
void DynamicErrors::addError(DynamicError&& e, UErrorCode& status) {
CHECK_ERROR(status);
+ DynamicErrorType type = e.type;
+
void* errorP = static_cast<void*>(create<DynamicError>(std::move(e), status));
U_ASSERT(resolutionAndFormattingErrors.isValid());
- switch (e.type) {
+ switch (type) {
case DynamicErrorType::UnresolvedVariable: {
unresolvedVariableError = true;
resolutionAndFormattingErrors->adoptElement(errorP, status);