0
0
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:
Bram Moolenaar 2019-04-19 15:20:46 +02:00
parent 86ec6d7e1e
commit 334ad41504
2 changed files with 4 additions and 7 deletions

View File

@ -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);
}
/*

View File

@ -771,6 +771,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1186,
/**/
1185,
/**/