1
0
forked from aniani/vim

patch 8.0.0883: invalid memory access with nonsensical script

Problem:    Invalid memory access with nonsensical script.
Solution:   Check "dstlen" being positive. (Dominique Pelle)
This commit is contained in:
Bram Moolenaar
2017-08-06 18:15:45 +02:00
parent 4535654246
commit 1c864093f9
2 changed files with 12 additions and 5 deletions

View File

@@ -4180,13 +4180,18 @@ expand_env_esc(
}
else if ((src[0] == ' ' || src[0] == ',') && !one)
at_start = TRUE;
*dst++ = *src++;
--dstlen;
if (dstlen > 0)
{
*dst++ = *src++;
--dstlen;
if (startstr != NULL && src - startstr_len >= srcp
&& STRNCMP(src - startstr_len, startstr, startstr_len) == 0)
at_start = TRUE;
if (startstr != NULL && src - startstr_len >= srcp
&& STRNCMP(src - startstr_len, startstr,
startstr_len) == 0)
at_start = TRUE;
}
}
}
*dst = NUL;
}