# HG changeset patch # User Bram Moolenaar # Date 1555680605 -7200 # Node ID 514e42de6a1ded5c511d9a1684dd393265179d6f # Parent d5dc4a56ba8a577b29b96866c91ab2ec68bcb6a6 patch 8.1.1186: readdir() allocates list twice commit https://github.com/vim/vim/commit/334ad415040f9592451ec99498cd99f90d6e33e6 Author: Bram Moolenaar Date: Fri Apr 19 15:20:46 2019 +0200 patch 8.1.1186: readdir() allocates list twice Problem: readdir() allocates list twice. Solution: Remove second allocation. Also check for zero length. diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -9324,10 +9324,8 @@ f_readdir(typval_T *argvars, typval_T *r } #endif - rettv->vval.v_list = list_alloc(); - if (!failed && rettv->vval.v_list != NULL) - { - ++rettv->vval.v_list->lv_refcount; + if (!failed && rettv->vval.v_list != NULL && ga.ga_len > 0) + { 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 *r 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); } /* diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -772,6 +772,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1186, +/**/ 1185, /**/ 1184,