+2015-01-28 Darin Adler <darin@apple.com>
+
+ Fix small leak in Collator
+ https://bugs.webkit.org/show_bug.cgi?id=140990
+
+ Reviewed by Andreas Kling.
+
+ * wtf/unicode/icu/CollatorICU.cpp:
+ (WTF::Collator::Collator): Use fastStrDup instead of strdup.
+ (WTF::Collator::~Collator): Use fastFree on the collator locale that we
+ are abandoning. The old code instead just called free on a null pointer.
+
2015-01-27 Geoffrey Garen <ggaren@apple.com>
Removed WTF_MALLOC_VALIDATION
ucol_setAttribute(m_collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
ASSERT(U_SUCCESS(status));
- m_locale = locale ? strdup(locale) : nullptr;
+ m_locale = locale ? fastStrDup(locale) : nullptr;
m_shouldSortLowercaseFirst = shouldSortLowercaseFirst;
}
Collator::~Collator()
{
- {
- std::lock_guard<std::mutex> lock(cachedCollatorMutex());
- if (cachedCollator)
- ucol_close(cachedCollator);
- cachedCollator = m_collator;
- cachedCollatorLocale = m_locale;
- cachedCollatorShouldSortLowercaseFirst = m_shouldSortLowercaseFirst;
- m_collator = nullptr;
- m_locale = nullptr;
+ std::lock_guard<std::mutex> lock(cachedCollatorMutex());
+ if (cachedCollator) {
+ ucol_close(cachedCollator);
+ fastFree(cachedCollatorLocale);
}
-
- free(m_locale);
+ cachedCollator = m_collator;
+ cachedCollatorLocale = m_locale;
+ cachedCollatorShouldSortLowercaseFirst = m_shouldSortLowercaseFirst;
}
static int32_t getIndexLatin1(UCharIterator* iterator, UCharIteratorOrigin origin)