ICU-22796 Bugfix: Memory access after uprv_free().

This commit is contained in:
David Yeung 2024-05-22 10:07:02 -07:00 committed by Frank Yung-Fong Tang
parent 697cb14f08
commit 6e9e120520

View file

@ -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;