diff options
author | Kurt Zenker <kz@openoffice.org> | 2005-07-01 12:18:50 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2005-07-01 12:18:50 +0000 |
commit | 034607b08e8618374695542cdfd70b3acab1c56f (patch) | |
tree | e2bf8b6ed0f98fa38935bd4ae65092d4da33e170 /sal | |
parent | 3b6262109b1db97e9b80f6df01a837e6793c2e87 (diff) |
INTEGRATION: CWS memory01 (1.24.154); FILE MERGED
2005/06/20 13:38:43 obr 1.24.154.1: #i49516# fixed memory leak in _parse_locale
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/nlsupport.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/sal/osl/unx/nlsupport.c b/sal/osl/unx/nlsupport.c index c4c6795223c4..2eab299200e3 100644 --- a/sal/osl/unx/nlsupport.c +++ b/sal/osl/unx/nlsupport.c @@ -2,9 +2,9 @@ * * $RCSfile: nlsupport.c,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: rt $ $Date: 2004-03-30 16:29:07 $ + * last change: $Author: kz $ $Date: 2005-07-01 13:18:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -213,10 +213,6 @@ static rtl_Locale * _parse_locale( const char * locale ) { static sal_Unicode c_locale[2] = { (sal_Unicode) 'C', 0 }; - rtl_uString * pLanguage = NULL; - rtl_uString * pCountry = NULL; - rtl_uString * pVariant = NULL; - /* check if locale contains a valid string */ if( locale ) { @@ -224,6 +220,10 @@ static rtl_Locale * _parse_locale( const char * locale ) if( len >= 2 ) { + rtl_uString * pLanguage = NULL; + rtl_uString * pCountry = NULL; + rtl_uString * pVariant = NULL; + size_t offset = 2; /* convert language code to unicode */ @@ -244,7 +244,13 @@ static rtl_Locale * _parse_locale( const char * locale ) OSL_ASSERT(pVariant != NULL); } - return rtl_locale_register( pLanguage->buffer, pCountry ? pCountry->buffer : c_locale + 1, pVariant ? pVariant->buffer : c_locale + 1 ); + rtl_Locale * ret = rtl_locale_register( pLanguage->buffer, pCountry ? pCountry->buffer : c_locale + 1, pVariant ? pVariant->buffer : c_locale + 1 ); + + if (pVariant) rtl_uString_release(pVariant); + if (pCountry) rtl_uString_release(pCountry); + if (pLanguage) rtl_uString_release(pLanguage); + + return ret; } else return rtl_locale_register( c_locale, c_locale + 1, c_locale + 1 ); |