diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-05-26 14:25:58 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-05-26 14:25:58 +0200 |
commit | 0fe40023df5d28a46bea5632835f65e11e1954c0 (patch) | |
tree | 516e42f9049384dd049fe70aaeb487904fb90a93 /i18nlangtag | |
parent | external/liblangtag: Fix memory leak (diff) | |
download | core-0fe40023df5d28a46bea5632835f65e11e1954c0.tar.gz core-0fe40023df5d28a46bea5632835f65e11e1954c0.zip |
Fix refcounting
Change-Id: I2225b2a2dc0648ec3b9e2af251cd1a3502199383
Diffstat (limited to 'i18nlangtag')
-rw-r--r-- | i18nlangtag/source/languagetag/languagetag.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx index 8a96bde83f81..483cf98af7da 100644 --- a/i18nlangtag/source/languagetag/languagetag.cxx +++ b/i18nlangtag/source/languagetag/languagetag.cxx @@ -429,8 +429,10 @@ LanguageTagImpl& LanguageTagImpl::operator=( const LanguageTagImpl & rLanguageTa maCachedScript = rLanguageTagImpl.maCachedScript; maCachedCountry = rLanguageTagImpl.maCachedCountry; maCachedVariants = rLanguageTagImpl.maCachedVariants; + lt_tag_t * oldTag = mpImplLangtag; mpImplLangtag = rLanguageTagImpl.mpImplLangtag ? lt_tag_copy( rLanguageTagImpl.mpImplLangtag) : NULL; + lt_tag_unref(oldTag); mnLangID = rLanguageTagImpl.mnLangID; meIsValid = rLanguageTagImpl.meIsValid; meIsIsoLocale = rLanguageTagImpl.meIsIsoLocale; @@ -444,8 +446,10 @@ LanguageTagImpl& LanguageTagImpl::operator=( const LanguageTagImpl & rLanguageTa mbCachedScript = rLanguageTagImpl.mbCachedScript; mbCachedCountry = rLanguageTagImpl.mbCachedCountry; mbCachedVariants = rLanguageTagImpl.mbCachedVariants; - if (mpImplLangtag) + if (mpImplLangtag && !oldTag) theDataRef::get().incRef(); + else if (!mpImplLangtag && oldTag) + theDataRef::get().decRef(); return *this; } |