1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-01 04:14:16 -04:00

fix accessing unallocated text when checking entry position

fixes #928
This commit is contained in:
ailin-nemui 2018-09-04 14:12:03 +02:00
parent 7f14d4d744
commit 74e8371bde

View File

@ -212,7 +212,7 @@ static int pos2scrpos(GUI_ENTRY_REC *entry, int pos, int cursor)
xpos += scrlen_str(entry->extents[0], entry->utf8);
}
for (i = 0; i < pos; i++) {
for (i = 0; i < entry->text_len && i < pos; i++) {
unichar c = entry->text[i];
const char *extent = entry->uses_extents ? entry->extents[i+1] : NULL;
@ -226,9 +226,8 @@ static int pos2scrpos(GUI_ENTRY_REC *entry, int pos, int cursor)
if (extent != NULL) {
xpos += scrlen_str(extent, entry->utf8);
}
}
return xpos;
return xpos + pos - i;
}
static int scrpos2pos(GUI_ENTRY_REC *entry, int pos)