summaryrefslogtreecommitdiff
path: root/lingucomponent
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-10-04 22:02:53 +0200
committerJulien Nabet <serval2412@yahoo.fr>2017-10-05 06:38:00 +0200
commitcfce9b418072ff930d400890dcc0781e919fce24 (patch)
treecd412b2b6d78818f820375dcbf798592c9b5e3a6 /lingucomponent
parentad0e0cb25c7943663f6c946fd300bff83e4caa59 (diff)
Fix potential leak in macspellimp.mm
+ avoid macSpell var I'm not sure to retrieve [NSSpellChecker sharedSpellChecker] in a pointer is a good idea. Most of the examples using sharedSpellChecker just call [NSSpellChecker sharedSpellChecker] each time. If there's a bit more code, at least we're sure we won't leak because of this. Change-Id: I9818bd3d51f26b50849e1a5e69cc705acd92ad29 Reviewed-on: https://gerrit.libreoffice.org/43140 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'lingucomponent')
-rw-r--r--lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx1
-rw-r--r--lingucomponent/source/spellcheck/macosxspell/macspellimp.mm9
2 files changed, 4 insertions, 6 deletions
diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx b/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx
index 7c72b748c7b2..c489bee337f2 100644
--- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx
+++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx
@@ -63,7 +63,6 @@ class MacSpellChecker :
Locale * aDLocs;
OUString * aDNames;
sal_Int32 numdict;
- NSSpellChecker * macSpell;
int macTag; // unique tag for this doc
::comphelper::OInterfaceContainerHelper2 aEvtListeners;
diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm
index f146db7b8dab..4519e2a98fd7 100644
--- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm
+++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm
@@ -57,7 +57,6 @@ MacSpellChecker::MacSpellChecker() :
numdict = 0;
NSApplicationLoad();
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- macSpell = [NSSpellChecker sharedSpellChecker];
macTag = [NSSpellChecker uniqueSpellDocumentTag];
[pool release];
}
@@ -117,7 +116,7 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales()
for (NSUInteger i = 0; i < [aLocales count]; i++)
{
NSString* pLangStr = (NSString*)[aLocales objectAtIndex:i];
- if( [macSpell setLanguage:pLangStr ] )
+ if( [[NSSpellChecker sharedSpellChecker] setLanguage:pLangStr ] )
{
postspdict.push_back( pLangStr );
}
@@ -241,7 +240,7 @@ sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale
}
NSInteger aCount;
- NSRange range = [macSpell checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:false inSpellDocumentWithTag:macTag wordCount:&aCount];
+ NSRange range = [[NSSpellChecker sharedSpellChecker] checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:false inSpellDocumentWithTag:macTag wordCount:&aCount];
int rVal = 0;
if(range.length>0)
{
@@ -339,8 +338,8 @@ Reference< XSpellAlternatives >
NSString* aTaggedCountry = [@"_" stringByAppendingString:aCountry];
aLang = [aLang stringByAppendingString:aTaggedCountry];
}
- [macSpell setLanguage:aLang];
- NSArray *guesses = [macSpell guessesForWordRange:NSMakeRange(0, [aNSStr length]) inString:aNSStr language:aLang inSpellDocumentWithTag:0];
+ [[NSSpellChecker sharedSpellChecker] setLanguage:aLang];
+ NSArray *guesses = [[NSSpellChecker sharedSpellChecker] guessesForWordRange:NSMakeRange(0, [aNSStr length]) inString:aNSStr language:aLang inSpellDocumentWithTag:0];
count = [guesses count];
if (count)
{