diff --git a/icu4c/source/common/icunotif.h b/icu4c/source/common/icunotif.h index 4486f6786dd..f769f4fbbd9 100644 --- a/icu4c/source/common/icunotif.h +++ b/icu4c/source/common/icunotif.h @@ -85,9 +85,12 @@ class U_COMMON_API ICUNotifier : public UMemory { } virtual ~ICUNotifier(void) { - Mutex lmx(¬ifyLock); - delete listeners; - listeners = NULL; + { + Mutex lmx(¬ifyLock); + delete listeners; + listeners = NULL; + } + umtx_destroy(¬ifyLock); } /** diff --git a/icu4c/source/common/icuserv.cpp b/icu4c/source/common/icuserv.cpp index 7f66c268051..44da75cfaa4 100644 --- a/icu4c/source/common/icuserv.cpp +++ b/icu4c/source/common/icuserv.cpp @@ -716,6 +716,7 @@ ICUService::getKey(ICUServiceKey& key, UnicodeString* actualReturn, const ICUSer UObject* service = f->create(key, this, status); if (U_FAILURE(status)) { delete cacheDescriptorList; + delete service; return NULL; } if (service != NULL) { diff --git a/icu4c/source/test/intltest/icusvtst.cpp b/icu4c/source/test/intltest/icusvtst.cpp index 6d4d59d045d..fd45e5d7d04 100644 --- a/icu4c/source/test/intltest/icusvtst.cpp +++ b/icu4c/source/test/intltest/icusvtst.cpp @@ -637,7 +637,6 @@ ICUServiceTest::testAPI_Two() service.registerFactory(f, status); } - // iterate over the visual ids returned by the multiple factory { UErrorCode status = U_ZERO_ERROR; @@ -648,6 +647,7 @@ ICUServiceTest::testAPI_Two() UnicodeString* result = (UnicodeString*)service.get(*id, status); if (result) { logln(" " + *id + " --> " + *result); + delete result; } else { errln("could not find " + *id); } @@ -1361,6 +1361,8 @@ void ICUServiceTest::testCoverage() delete obj; } + delete key; + #if 0 // ResourceBundleFactory ICUResourceBundleFactory rbf = new ICUResourceBundleFactory();