mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.1186: readdir() allocates list twice
Problem: readdir() allocates list twice. Solution: Remove second allocation. Also check for zero length.
This commit is contained in:
parent
86ec6d7e1e
commit
334ad41504
@ -9324,10 +9324,8 @@ f_readdir(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
#endif
|
||||
|
||||
rettv->vval.v_list = list_alloc();
|
||||
if (!failed && rettv->vval.v_list != NULL)
|
||||
if (!failed && rettv->vval.v_list != NULL && ga.ga_len > 0)
|
||||
{
|
||||
++rettv->vval.v_list->lv_refcount;
|
||||
sort_strings((char_u **)ga.ga_data, ga.ga_len);
|
||||
for (i = 0; i < ga.ga_len; i++)
|
||||
{
|
||||
@ -9335,10 +9333,7 @@ f_readdir(typval_T *argvars, typval_T *rettv)
|
||||
list_append_string(rettv->vval.v_list, p, -1);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < ga.ga_len; i++)
|
||||
vim_free(((char_u **)ga.ga_data)[i]);
|
||||
|
||||
ga_clear(&ga);
|
||||
ga_clear_strings(&ga);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -771,6 +771,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1186,
|
||||
/**/
|
||||
1185,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user