mattt/TTTAttributedLabel — Issue #41: Crash in characterAtIndexPoint: when tapping on plaintext label
Author: LongWeekend
Created: 2011-12-13 10:05:47+00:00
State: open

This method uses this call:

CTFrameRef frame = CTFramesetterCreateFrame(self.framesetter, CFRangeMake(0, [self.attributedText length]), path, NULL);

However, if the user is not using an attributed string, and just using plain old text, self.attributedText is nil, which causes this method to crash 2 lines later on:

CFArrayRef lines = CTFrameGetLines(frame);
NSUInteger numberOfLines = CFArrayGetCount(lines);

Because "lines" is not a valid array (and frame is 0x0 as well), yet we're calling CFArrayGetCount() on it. EXC_BAD_ACCESS.

Should this method simply do a "quick return" at the top if the attributed string is nil?