diff options
author | Daniel Veillard <veillard@redhat.com> | 2011-02-28 09:54:15 +0800 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2011-02-28 09:54:15 +0800 |
commit | 7f741527832f4d85472c61f0468c1358f84810d7 (patch) | |
tree | d605600af78b0f21e1c32e223b83b4d24a943c3c | |
parent | ecb6bcb8d1b7e44842edde3929f412d46b40c89f (diff) | |
download | libxslt-7f741527832f4d85472c61f0468c1358f84810d7.tar.gz libxslt-7f741527832f4d85472c61f0468c1358f84810d7.tar.bz2 libxslt-7f741527832f4d85472c61f0468c1358f84810d7.zip |
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
-rw-r--r-- | libxslt/extensions.c | 1 | ||||
-rw-r--r-- | libxslt/xslt.c | 4 | ||||
-rw-r--r-- | libxslt/xsltlocale.c | 15 | ||||
-rw-r--r-- | libxslt/xsltlocale.h | 1 |
4 files changed, 21 insertions, 0 deletions
diff --git a/libxslt/extensions.c b/libxslt/extensions.c index 6187b7af..f6f021eb 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 8e8c414b..6293bb33 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 2caa2ec8..70a0b99f 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 59343b0a..9af4adce 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__ */ |