From 90318f8895717ac70cde362ec5ca9d4d0a6dbadb Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Thu, 2 Apr 2009 20:29:06 +0000 Subject: [PATCH] ICU-6554 Delete/close objects or pointers to avoid memory leaks. X-SVN-Rev: 25725 --- icu4c/source/i18n/colldata.cpp | 4 ++++ icu4c/source/test/intltest/caltest.cpp | 1 + icu4c/source/test/intltest/ssearch.cpp | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/icu4c/source/i18n/colldata.cpp b/icu4c/source/i18n/colldata.cpp index d313e3871e..5784b83c26 100644 --- a/icu4c/source/i18n/colldata.cpp +++ b/icu4c/source/i18n/colldata.cpp @@ -903,6 +903,10 @@ int32_t CollData::minLengthInChars(const CEList *ceList, int32_t offset, int32_t rlength = minLengthInChars(ceList, roffset, history); if (rlength <= 0) { + // delete before continue to avoid memory leak. +#ifndef CACHE_CELISTS + delete ceList2; +#endif // ignore any dead ends continue; } diff --git a/icu4c/source/test/intltest/caltest.cpp b/icu4c/source/test/intltest/caltest.cpp index b49848562a..8d68a7ad62 100644 --- a/icu4c/source/test/intltest/caltest.cpp +++ b/icu4c/source/test/intltest/caltest.cpp @@ -2052,6 +2052,7 @@ void CalendarTest::Test3785() if (U_FAILURE(status)) return; //printf("formatted: '%s'\n", mkcstr(ubuffer)); + udat_close(df); return; } diff --git a/icu4c/source/test/intltest/ssearch.cpp b/icu4c/source/test/intltest/ssearch.cpp index 5b3071b816..c887062d6f 100644 --- a/icu4c/source/test/intltest/ssearch.cpp +++ b/icu4c/source/test/intltest/ssearch.cpp @@ -1856,11 +1856,12 @@ static UBool simpleSearch(UCollator *coll, const UnicodeString &target, int32_t int32_t targetSize = targetOrders.size() - 1; int32_t patternSize = patternOrders.size() - 1; UBreakIterator *charBreakIterator = ubrk_open(UBRK_CHARACTER, ucol_getLocale(coll, ULOC_VALID_LOCALE, &status), - target.getBuffer(), target.length(), &status); + target.getBuffer(), target.length(), &status); if (patternSize == 0) { // Searching for an empty pattern always fails matchStart = matchEnd = -1; + ubrk_close(charBreakIterator); return FALSE; }