Skip to content

Commit d297f35

Browse files
committed
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().
1 parent 80627cf commit d297f35

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/evalfunc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2819,7 +2819,17 @@ f_execute(typval_T *argvars, typval_T *rettv)
28192819
--list->lv_refcount;
28202820
}
28212821

2822-
rettv->vval.v_string = redir_execute_ga.ga_data;
2822+
/* Need to append a NUL to the result. */
2823+
if (ga_grow(&redir_execute_ga, 1) == OK)
2824+
{
2825+
((char *)redir_execute_ga.ga_data)[redir_execute_ga.ga_len] = NUL;
2826+
rettv->vval.v_string = redir_execute_ga.ga_data;
2827+
}
2828+
else
2829+
{
2830+
ga_clear(&redir_execute_ga);
2831+
rettv->vval.v_string = NULL;
2832+
}
28232833
msg_silent = save_msg_silent;
28242834
emsg_silent = save_emsg_silent;
28252835
emsg_noredir = save_emsg_noredir;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
264,
767769
/**/
768770
263,
769771
/**/

0 commit comments

Comments
 (0)