diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index a85a043a32..fa4156574b 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -1203,21 +1203,23 @@ - (void)batchDrawData:(NSData *)data CTRunRef run = (CTRunRef)item; CFIndex count = CTRunGetGlyphCount(run); - if (count > 0 && count - offset > length) - count = length - offset; - - CFRange range = CFRangeMake(0, count); - - if (glyphs != NULL) - CTRunGetGlyphs(run, range, &glyphs[offset]); - if (advances != NULL) - CTRunGetAdvances(run, range, &advances[offset]); - if (positions != NULL) - CTRunGetPositions(run, range, &positions[offset]); - - offset += count; - if (offset >= length) - break; + if (count > 0) { + if (count > length - offset) + count = length - offset; + + CFRange range = CFRangeMake(0, count); + + if (glyphs != NULL) + CTRunGetGlyphs(run, range, &glyphs[offset]); + if (advances != NULL) + CTRunGetAdvances(run, range, &advances[offset]); + if (positions != NULL) + CTRunGetPositions(run, range, &positions[offset]); + + offset += count; + if (offset >= length) + break; + } } return offset;