mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
ncwidth: fix heap overrun
This commit is contained in:
parent
4fa15e4256
commit
7fd93b5977
@ -11,12 +11,12 @@ static int
|
|||||||
add_wchar(wchar_t** wbuf, size_t* bufsize, size_t* used, wchar_t wc){
|
add_wchar(wchar_t** wbuf, size_t* bufsize, size_t* used, wchar_t wc){
|
||||||
if(*used == *bufsize){
|
if(*used == *bufsize){
|
||||||
const size_t GROW = 128;
|
const size_t GROW = 128;
|
||||||
wchar_t* tmp = realloc(*wbuf, *bufsize + GROW * sizeof(**wbuf));
|
wchar_t* tmp = realloc(*wbuf, (*bufsize + GROW) * sizeof(**wbuf));
|
||||||
if(tmp == NULL){
|
if(tmp == NULL){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*wbuf = tmp;
|
*wbuf = tmp;
|
||||||
*bufsize += GROW * sizeof(**wbuf);
|
*bufsize += GROW;
|
||||||
}
|
}
|
||||||
(*wbuf)[*used] = wc;
|
(*wbuf)[*used] = wc;
|
||||||
++*used;
|
++*used;
|
||||||
|
Loading…
Reference in New Issue
Block a user