From 6e9e120520b73b78961dd957cb3ce762ed560199 Mon Sep 17 00:00:00 2001 From: David Yeung Date: Wed, 22 May 2024 10:07:02 -0700 Subject: [PATCH] ICU-22796 Bugfix: Memory access after uprv_free(). --- icu4c/source/common/locid.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icu4c/source/common/locid.cpp b/icu4c/source/common/locid.cpp index 37bbe4ba949e..420338c289eb 100644 --- a/icu4c/source/common/locid.cpp +++ b/icu4c/source/common/locid.cpp @@ -2665,11 +2665,11 @@ Locale::setKeywordValue(const char* keywordName, const char* keywordValue, UErro } uprv_strcpy(newFullName, fullName); if (fullName != fullNameBuffer) { - // if full Name is already on the heap, need to free it. - uprv_free(fullName); if (baseName == fullName) { baseName = newFullName; // baseName should not point to freed memory. } + // if full Name is already on the heap, need to free it. + uprv_free(fullName); } fullName = newFullName; status = U_ZERO_ERROR;