1
0
mirror of https://github.com/irssi/irssi.git synced 2025-02-02 15:08:01 -05:00

Merge pull request #930 from ailin-nemui/fix-928

fix accessing unallocated text when checking entry position
This commit is contained in:
ailin-nemui 2018-09-20 17:37:50 +02:00 committed by GitHub
commit 708ba06dbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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); 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]; unichar c = entry->text[i];
const char *extent = entry->uses_extents ? entry->extents[i+1] : NULL; 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) { if (extent != NULL) {
xpos += scrlen_str(extent, entry->utf8); xpos += scrlen_str(extent, entry->utf8);
} }
} }
return xpos; return xpos + pos - i;
} }
static int scrpos2pos(GUI_ENTRY_REC *entry, int pos) static int scrpos2pos(GUI_ENTRY_REC *entry, int pos)