0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.0.0597: off-by-one error in size computation

Problem:    Off-by-one error in buffer size computation.
Solution:   Use ">=" instead of ">". (Lemonboy, closes #1694)
This commit is contained in:
Bram Moolenaar
2017-05-15 08:45:13 +02:00
parent 4475b62396
commit 253f912877
2 changed files with 5 additions and 3 deletions

View File

@@ -919,7 +919,7 @@ restofline:
}
if (fmt_ptr->flags == '+' && !qi->qf_multiscan) /* %+ */
{
if (linelen > fields->errmsglen)
if (linelen >= fields->errmsglen)
{
/* linelen + null terminator */
if ((fields->errmsg = vim_realloc(fields->errmsg,
@@ -934,7 +934,7 @@ restofline:
if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
continue;
len = (int)(regmatch.endp[i] - regmatch.startp[i]);
if (len > fields->errmsglen)
if (len >= fields->errmsglen)
{
/* len + null terminator */
if ((fields->errmsg = vim_realloc(fields->errmsg, len + 1))
@@ -1017,7 +1017,7 @@ restofline:
fields->namebuf[0] = NUL; /* no match found, remove file name */
fields->lnum = 0; /* don't jump to this line */
fields->valid = FALSE;
if (linelen > fields->errmsglen)
if (linelen >= fields->errmsglen)
{
/* linelen + null terminator */
if ((fields->errmsg = vim_realloc(fields->errmsg,