termiolink: hopefully fixes segfault. Closes T4896

This commit is contained in:
Boris Faure 2016-11-15 22:28:27 +01:00
parent 55db8930b2
commit cea49794a0
1 changed files with 3 additions and 1 deletions

View File

@ -73,6 +73,8 @@ _txt_at(Termpty *ty, int *x, int *y, char *txt, int *txtlenp)
cells = termpty_cellrow_get(ty, *y, &w);
if (!cells || !w)
goto bad;
if ((*x >= w))
*x = w-1;
cell = cells[*x];
if ((cell.codepoint == 0) && (cell.att.dblwidth))
{
@ -113,7 +115,7 @@ _txt_prev_at(Termpty *ty, int *x, int *y, char *txt, int *txtlenp)
cells = termpty_cellrow_get(ty, *y, &w);
if (!cells || !w)
goto bad;
if ((*x) < 0)
if (((*x) < 0) || ((*x) >= w))
*x = w-1;
cell = cells[*x];