Fix out of boundary write on 1x1 terminals
If a terminal is merely 1x1 in size, setsize() will write a nul byte in front of the allocated memory, which is an out of boundary write.
This commit is contained in:
parent
a2ceb95e2a
commit
03f5e2b7c5
2
tload.c
2
tload.c
@ -71,6 +71,8 @@ static void setsize(int i)
|
|||||||
nrows = win.ws_row;
|
nrows = win.ws_row;
|
||||||
}
|
}
|
||||||
scr_size = nrows * ncols;
|
scr_size = nrows * ncols;
|
||||||
|
if (scr_size < 2)
|
||||||
|
xerr(EXIT_FAILURE, _("screen too small"));
|
||||||
if (screen == NULL)
|
if (screen == NULL)
|
||||||
screen = (char *)xmalloc(scr_size);
|
screen = (char *)xmalloc(scr_size);
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user