diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-09-16 22:14:26 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-09-24 17:23:28 +0200 |
commit | 635ea3a8f12e3e7b0cc4283126e67b1057810029 (patch) | |
tree | 89fc5e8d3c1ad0ec6e2ca9a0bd9591ed7a423b95 | |
parent | f67f4c377dde9659251829e738173a7ceb975236 (diff) |
tdf#112425: fix 2 leaks in MacSpellChecker
by using "autorelease" keyword with init vars
corresponds to:
https://cgit.freedesktop.org/libreoffice/core/commit/?id=83288332f7ced698610739419989c464256f1c4d
+
https://cgit.freedesktop.org/libreoffice/core/commit/?id=11fcdecb631fef7797da9489ea36468e292e2986
Change-Id: I056282460b94f8052287f5ad29d26a4870cd06a5
Reviewed-on: https://gerrit.libreoffice.org/42361
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-on: https://gerrit.libreoffice.org/42703
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | lingucomponent/source/spellcheck/macosxspell/macspellimp.mm | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm index 68239d90e9ed..a967731de9f3 100644 --- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm +++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm @@ -232,14 +232,12 @@ sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale { aEnc = 0; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSString* aNSStr = [[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(nWord.getStr()) length: nWord.getLength()]; - NSString* aLang = [[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(rLocale.Language.getStr()) length: rLocale.Language.getLength()]; + NSString* aNSStr = [[[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(nWord.getStr()) length: nWord.getLength()]autorelease]; + NSString* aLang = [[[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(rLocale.Language.getStr()) length: rLocale.Language.getLength()]autorelease]; if(rLocale.Country.getLength()>0) { - NSString* aCountry = [[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(rLocale.Country.getStr()) length: rLocale.Country.getLength()]; - NSString* aTag = @"_"; - NSString* aTaggedCountry = [aTag stringByAppendingString:aCountry]; - [aLang autorelease]; + NSString* aCountry = [[[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(rLocale.Country.getStr()) length: rLocale.Country.getLength()]autorelease]; + NSString* aTaggedCountry = [@"_" stringByAppendingString:aCountry]; aLang = [aLang stringByAppendingString:aTaggedCountry]; } @@ -334,14 +332,12 @@ Reference< XSpellAlternatives > if (n) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSString* aNSStr = [[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(nWord.getStr()) length: nWord.getLength()]; - NSString* aLang = [[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(rLocale.Language.getStr()) length: rLocale.Language.getLength() ]; + NSString* aNSStr = [[[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(nWord.getStr()) length: nWord.getLength()]autorelease]; + NSString* aLang = [[[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(rLocale.Language.getStr()) length: rLocale.Language.getLength()]autorelease]; if(rLocale.Country.getLength()>0) { - NSString* aCountry = [[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(rLocale.Country.getStr()) length: rLocale.Country.getLength() ]; - NSString* aTag = @"_"; - NSString* aTaggedCountry = [aTag stringByAppendingString:aCountry]; - [aLang autorelease]; + NSString* aCountry = [[[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(rLocale.Country.getStr()) length: rLocale.Country.getLength()]autorelease]; + NSString* aTaggedCountry = [@"_" stringByAppendingString:aCountry]; aLang = [aLang stringByAppendingString:aTaggedCountry]; } [macSpell setLanguage:aLang]; |