mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #4592 from oni-link/fix.issue.4582
eval.c: Fix heap corruption error when constructing sourcing_name
This commit is contained in:
commit
cc1beecf81
@ -21038,15 +21038,22 @@ call_user_func (
|
|||||||
save_sourcing_name = sourcing_name;
|
save_sourcing_name = sourcing_name;
|
||||||
save_sourcing_lnum = sourcing_lnum;
|
save_sourcing_lnum = sourcing_lnum;
|
||||||
sourcing_lnum = 1;
|
sourcing_lnum = 1;
|
||||||
// need space for function name + ("function " + 3) or "[number]"
|
// need space for new sourcing_name:
|
||||||
|
// * save_sourcing_name
|
||||||
|
// * "["number"].." or "function "
|
||||||
|
// * "<SNR>" + fp->uf_name - 3
|
||||||
|
// * terminating NUL
|
||||||
size_t len = (save_sourcing_name == NULL ? 0 : STRLEN(save_sourcing_name))
|
size_t len = (save_sourcing_name == NULL ? 0 : STRLEN(save_sourcing_name))
|
||||||
+ STRLEN(fp->uf_name) + 20;
|
+ STRLEN(fp->uf_name) + 27;
|
||||||
sourcing_name = xmalloc(len);
|
sourcing_name = xmalloc(len);
|
||||||
{
|
{
|
||||||
if (save_sourcing_name != NULL
|
if (save_sourcing_name != NULL
|
||||||
&& STRNCMP(save_sourcing_name, "function ", 9) == 0) {
|
&& STRNCMP(save_sourcing_name, "function ", 9) == 0) {
|
||||||
vim_snprintf((char *)sourcing_name, len, "%s[%zu]..",
|
vim_snprintf((char *)sourcing_name,
|
||||||
save_sourcing_name, save_sourcing_lnum);
|
len,
|
||||||
|
"%s[%" PRId64 "]..",
|
||||||
|
save_sourcing_name,
|
||||||
|
(int64_t)save_sourcing_lnum);
|
||||||
} else {
|
} else {
|
||||||
STRCPY(sourcing_name, "function ");
|
STRCPY(sourcing_name, "function ");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user