[libxslt] Fix a memory leak if compiled with Windows locale support
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxslt] Fix a memory leak if compiled with Windows locale support
- Date: Fri, 4 Mar 2011 10:35:47 +0000 (UTC)
commit 7f741527832f4d85472c61f0468c1358f84810d7
Author: Daniel Veillard <veillard redhat com>
Date: Mon Feb 28 09:54:15 2011 +0800
Fix a memory leak if compiled with Windows locale support
Ralf Junker <ralfjunker gmx de> pointed out a ouple of leaks in the
Windows locale support:
* libxslt/xslt.c: add cleanup code for the mutex in xsltUninit()
* libxslt/xsltlocale.c libxslt/xsltlocale.h: add a new cleanup function
xsltFreeLocales
* libxslt/extensions.c: add a call to xsltFreeLocales in xsltCleanupGlobals
libxslt/extensions.c | 1 +
libxslt/xslt.c | 4 ++++
libxslt/xsltlocale.c | 15 +++++++++++++++
libxslt/xsltlocale.h | 1 +
4 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/libxslt/extensions.c b/libxslt/extensions.c
index 6187b7a..f6f021e 100644
--- a/libxslt/extensions.c
+++ b/libxslt/extensions.c
@@ -2289,6 +2289,7 @@ xsltCleanupGlobals(void)
xmlFreeMutex(xsltExtMutex);
xsltExtMutex = NULL;
+ xsltFreeLocales();
xsltUninit();
}
diff --git a/libxslt/xslt.c b/libxslt/xslt.c
index 8e8c414..6293bb3 100644
--- a/libxslt/xslt.c
+++ b/libxslt/xslt.c
@@ -243,6 +243,10 @@ xsltInit (void) {
*/
void
xsltUninit (void) {
+#ifdef XSLT_LOCALE_WINAPI
+ xmlFreeRMutex(xsltLocaleMutex);
+ xsltLocaleMutex = NULL;
+#endif
initialized = 0;
}
diff --git a/libxslt/xsltlocale.c b/libxslt/xsltlocale.c
index 2caa2ec..70a0b99 100644
--- a/libxslt/xsltlocale.c
+++ b/libxslt/xsltlocale.c
@@ -67,6 +67,21 @@ static void xsltEnumSupportedLocales(void);
#endif
/**
+ * xsltFreeLocales:
+ *
+ * Cleanup function for the locale support on shutdown
+ */
+void
+xsltFreeLocales(void) {
+#ifdef XSLT_LOCALE_WINAPI
+ xmlRMutexLock(xsltLocaleMutex);
+ xmlFree(xsltLocaleList);
+ xsltLocaleList = NULL;
+ xmlRMutexUnlock(xsltLocaleMutex);
+#endif
+}
+
+/**
* xsltNewLocale:
* @languageTag: RFC 3066 language tag
*
diff --git a/libxslt/xsltlocale.h b/libxslt/xsltlocale.h
index 59343b0..9af4adc 100644
--- a/libxslt/xsltlocale.h
+++ b/libxslt/xsltlocale.h
@@ -53,5 +53,6 @@ xsltLocale xsltNewLocale(const xmlChar *langName);
void xsltFreeLocale(xsltLocale locale);
xsltLocaleChar *xsltStrxfrm(xsltLocale locale, const xmlChar *string);
int xsltLocaleStrcmp(xsltLocale locale, const xsltLocaleChar *str1, const xsltLocaleChar *str2);
+void xsltFreeLocales(void);
#endif /* __XML_XSLTLOCALE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]