NSLinguisticTagger crashes when being fed a whitespace-only string

Originator:friedrich.markgraf
Number:rdar://16972528 Date Originated:2014-05-20
Status:open Resolved:
Product:OS X SDK Product Version:
Classification:crash Reproducible:always
 
Trying to use NSLinguisticTagger to find a word in a string of only whitespace crashes hard with an EXC_BAD_ACCESS. See attached sample project.

Steps to Reproduce:
1. Have a string containing only spaces (or only tabs, or spaces and newlines, etc.)
2. Use NSLinguisticTagger on it
3. Instead of great success, EXC_BAD_ACCESS :(

Code from sample project:

NSLinguisticTagger* tagger = [[NSLinguisticTagger alloc] initWithTagSchemes:@[NSLinguisticTagSchemeTokenType]
                                                                        options:0];
    tagger.string = @"                  "; //spaces only
    
    NSRange range;
    NSString *tag = [tagger tagAtIndex:2
                                scheme:NSLinguisticTagSchemeTokenType
                            tokenRange:&range
                         sentenceRange:NULL];

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!