From d89c4909f8efdeaf9fb919a133fcc8540855f022 Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Fri, 30 Aug 2019 20:44:42 -0700 Subject: [PATCH] ICU-20802 Need to use LocalMemory in uloc_openKeywordList, not LocalPointer --- icu4c/source/common/uloc.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp index d58bdfa64e9..6a9bfcfbff5 100644 --- a/icu4c/source/common/uloc.cpp +++ b/icu4c/source/common/uloc.cpp @@ -1457,22 +1457,19 @@ static const UEnumeration gKeywordsEnum = { U_CAPI UEnumeration* U_EXPORT2 uloc_openKeywordList(const char *keywordList, int32_t keywordListSize, UErrorCode* status) { - LocalPointer myContext; - LocalPointer result; + LocalMemory myContext; + LocalMemory result; if (U_FAILURE(*status)) { return nullptr; } - result.adoptInsteadAndCheckErrorCode(static_cast(uprv_malloc(sizeof(UEnumeration))), *status); - if (U_FAILURE(*status)) { + myContext.adoptInstead(static_cast(uprv_malloc(sizeof(UKeywordsContext)))); + result.adoptInstead(static_cast(uprv_malloc(sizeof(UEnumeration)))); + if (myContext.isNull() || result.isNull()) { + *status = U_MEMORY_ALLOCATION_ERROR; return nullptr; } uprv_memcpy(result.getAlias(), &gKeywordsEnum, sizeof(UEnumeration)); - - myContext.adoptInsteadAndCheckErrorCode(static_cast(uprv_malloc(sizeof(UKeywordsContext))), *status); - if (U_FAILURE(*status)) { - return nullptr; - } myContext->keywords = static_cast(uprv_malloc(keywordListSize+1)); if (myContext->keywords == nullptr) { *status = U_MEMORY_ALLOCATION_ERROR; -- 2.40.0