0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

patch 8.2.5161: might still access invalid memory

Problem:    Might still access invalid memory.
Solution:   Add extra check for negative value.
This commit is contained in:
Bram Moolenaar 2022-06-26 11:17:10 +01:00
parent e178af5a58
commit 0fbc9260a7
2 changed files with 5 additions and 1 deletions

View File

@ -949,8 +949,10 @@ msg_may_trunc(int force, char_u *s)
int n;
int room;
// If something unexpected happened "room" may be negative, check for that
// just in case.
room = (int)(Rows - cmdline_row - 1) * Columns + sc_col - 1;
if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
if (room > 0 && (force || (shortmess(SHM_TRUNC) && !exmode_active))
&& (n = (int)STRLEN(s) - room) > 0)
{
if (has_mbyte)

View File

@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
5161,
/**/
5160,
/**/