| diff --git a/source/common/locid.cpp b/source/common/locid.cpp |
| index ee791ae9..cf1ba227 100644 |
| --- a/source/common/locid.cpp |
| +++ b/source/common/locid.cpp |
| @@ -254,7 +254,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Locale) |
| |
| Locale::~Locale() |
| { |
| - if (baseName != fullName) { |
| + if ((baseName != fullName) && (baseName != fullNameBuffer)) { |
| uprv_free(baseName); |
| } |
| baseName = NULL; |
| @@ -466,7 +466,7 @@ Locale& Locale::operator=(const Locale& other) { |
| } |
| |
| Locale& Locale::operator=(Locale&& other) U_NOEXCEPT { |
| - if (baseName != fullName) uprv_free(baseName); |
| + if ((baseName != fullName) && (baseName != fullNameBuffer)) uprv_free(baseName); |
| if (fullName != fullNameBuffer) uprv_free(fullName); |
| |
| if (other.fullName == other.fullNameBuffer || other.baseName == other.fullNameBuffer) { |
| @@ -1853,7 +1853,7 @@ Locale& Locale::init(const char* localeID, UBool canonicalize) |
| { |
| fIsBogus = FALSE; |
| /* Free our current storage */ |
| - if (baseName != fullName) { |
| + if ((baseName != fullName) && (baseName != fullNameBuffer)) { |
| uprv_free(baseName); |
| } |
| baseName = NULL; |
| @@ -1889,6 +1889,7 @@ Locale& Locale::init(const char* localeID, UBool canonicalize) |
| uloc_getName(localeID, fullName, sizeof(fullNameBuffer), &err); |
| |
| if(err == U_BUFFER_OVERFLOW_ERROR || length >= (int32_t)sizeof(fullNameBuffer)) { |
| + U_ASSERT(baseName == nullptr); |
| /*Go to heap for the fullName if necessary*/ |
| fullName = (char *)uprv_malloc(sizeof(char)*(length + 1)); |
| if(fullName == 0) { |
| @@ -2042,7 +2043,7 @@ Locale::hashCode() const |
| void |
| Locale::setToBogus() { |
| /* Free our current storage */ |
| - if(baseName != fullName) { |
| + if((baseName != fullName) && (baseName != fullNameBuffer)) { |
| uprv_free(baseName); |
| } |
| baseName = NULL; |