1
0
forked from aniani/vim

patch 8.0.0264: memory error reported by ubsan

Problem:    Memory error reported by ubsan, probably for using the string
            returned by execute().
Solution:   NUL terminate the result of execute().
This commit is contained in:
Bram Moolenaar
2017-01-29 20:31:21 +01:00
parent 80627cf51f
commit d297f35eb0
2 changed files with 13 additions and 1 deletions

View File

@@ -2819,7 +2819,17 @@ f_execute(typval_T *argvars, typval_T *rettv)
--list->lv_refcount;
}
rettv->vval.v_string = redir_execute_ga.ga_data;
/* Need to append a NUL to the result. */
if (ga_grow(&redir_execute_ga, 1) == OK)
{
((char *)redir_execute_ga.ga_data)[redir_execute_ga.ga_len] = NUL;
rettv->vval.v_string = redir_execute_ga.ga_data;
}
else
{
ga_clear(&redir_execute_ga);
rettv->vval.v_string = NULL;
}
msg_silent = save_msg_silent;
emsg_silent = save_emsg_silent;
emsg_noredir = save_emsg_noredir;