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

fix accessing unallocated text when checking entry position

(cherry picked from commit 708ba06dbc30dcec99cf057a1f36fc9857308b72)
This commit is contained in:
ailin-nemui 2018-09-20 17:37:50 +02:00
parent 5216d091c9
commit 2d803ddd66

View File

@ -171,7 +171,7 @@ static int pos2scrpos(GUI_ENTRY_REC *entry, int pos)
int i;
int xpos = 0;
for (i = 0; i < pos; i++) {
for (i = 0; i < entry->text_len && i < pos; i++) {
unichar c = entry->text[i];
if (term_type == TERM_TYPE_BIG5)
@ -181,7 +181,7 @@ static int pos2scrpos(GUI_ENTRY_REC *entry, int pos)
else
xpos++;
}
return xpos;
return xpos + pos - i;
}
static int scrpos2pos(GUI_ENTRY_REC *entry, int pos)