Skip to content

Commit 334ad41

Browse files
committed
patch 8.1.1186: readdir() allocates list twice
Problem: readdir() allocates list twice. Solution: Remove second allocation. Also check for zero length.
1 parent 86ec6d7 commit 334ad41

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/evalfunc.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9324,21 +9324,16 @@ f_readdir(typval_T *argvars, typval_T *rettv)
93249324
}
93259325
#endif
93269326

9327-
rettv->vval.v_list = list_alloc();
9328-
if (!failed && rettv->vval.v_list != NULL)
9327+
if (!failed && rettv->vval.v_list != NULL && ga.ga_len > 0)
93299328
{
9330-
++rettv->vval.v_list->lv_refcount;
93319329
sort_strings((char_u **)ga.ga_data, ga.ga_len);
93329330
for (i = 0; i < ga.ga_len; i++)
93339331
{
93349332
p = ((char_u **)ga.ga_data)[i];
93359333
list_append_string(rettv->vval.v_list, p, -1);
93369334
}
93379335
}
9338-
for (i = 0; i < ga.ga_len; i++)
9339-
vim_free(((char_u **)ga.ga_data)[i]);
9340-
9341-
ga_clear(&ga);
9336+
ga_clear_strings(&ga);
93429337
}
93439338

93449339
/*

src/version.c

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

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1186,
774776
/**/
775777
1185,
776778
/**/

0 commit comments

Comments
 (0)