diff options
author | Victor Chang <vichang@google.com> | 2024-05-15 13:34:32 +0100 |
---|---|---|
committer | Victor Chang <vichang@google.com> | 2024-05-15 13:38:37 +0100 |
commit | 11098a983d9e0af1d4859d440fa7ab74960207fe (patch) | |
tree | 52461592fb3f1ccf728d94ce85942a846ee304be | |
parent | 355a301ffec53fc1f15ea5ed33f0dcb50815a68c (diff) | |
download | icu-main.tar.gz |
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.cpp | 8 |
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); |