Fix out-of-bounds memory access in Fl_Text_Display (STR #2730).

This bug would only show up in wrap mode.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10415 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2014-10-30 11:47:46 +00:00
parent 637ead9f99
commit c3c5659479

View File

@ -3369,9 +3369,13 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
if (b<lineStart) b = lineStart;
if (!foundBreak) { /* no whitespace, just break at margin */
newLineStart = max(p, buf->next_char(lineStart));
const char *s = buf->address(b);
colNum++;
width = measure_proportional_character(s, 0, p+styleBufOffset);
if (b >= buf->length()) { // STR #2730
width = 0;
} else {
const char *s = buf->address(b);
width = measure_proportional_character(s, 0, p+styleBufOffset);
}
}
if (p >= maxPos) {
*retPos = maxPos;