diff --git a/ChangeLog b/ChangeLog index 80dead287..ac87b6be6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-10-31 Fred Kiefer + + * Source/NSLayoutManager.m + (-drawBackgroundForGlyphRange:atPoint:): Make save against + glyph_run being null. Should fix part of #43454. + 2014-10-25 Fred Kiefer * Source/NSParagraphStyle.m, diff --git a/Source/NSLayoutManager.m b/Source/NSLayoutManager.m index 873c29b1b..7cba4ed79 100644 --- a/Source/NSLayoutManager.m +++ b/Source/NSLayoutManager.m @@ -1408,12 +1408,14 @@ container i = range.location - glyph_pos; last_color = nil; first_char_pos = char_pos; - while (1) + while ((glyph_run != nil) && (i + glyph_pos < range.location + range.length)) { NSRange r = NSMakeRange(glyph_pos + i, glyph_run->head.glyph_length - i); if (NSMaxRange(r) > NSMaxRange(range)) - r.length = NSMaxRange(range) - r.location; + { + r.length = NSMaxRange(range) - r.location; + } color = [_textStorage attribute: NSBackgroundColorAttributeName atIndex: char_pos @@ -1446,8 +1448,6 @@ container char_pos += glyph_run->head.char_length; i = 0; glyph_run = (glyph_run_t *)glyph_run->head.next; - if (i + glyph_pos >= range.location + range.length) - break; } if (!_selected_range.length || _selected_range.location == NSNotFound)