Avoid crash when inserting space in the middle of misspelled character

This is a fixup to commit 4796e6b3.
This commit is contained in:
Jean-Marc Lasgouttes 2015-07-15 20:36:51 +02:00
parent 605b933ec2
commit cb0dbfdadb

View File

@ -230,7 +230,8 @@ void RowPainter::paintMisspelledMark(double const orig_x,
FontMetrics const & fm = theFontMetrics(font);
int x1 = fm.pos2x(str, range.first - start_pos,
font.isVisibleRightToLeft());
int x2 = fm.pos2x(str, range.last - start_pos + 1,
int x2 = fm.pos2x(str, min(range.last - start_pos + 1,
pos_type(str.length())),
font.isVisibleRightToLeft());
if (x1 > x2)
swap(x1, x2);