mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
vim-patch:8.1.1186: readdir() allocates list twice
Problem: readdir() allocates list twice.
Solution: Remove second allocation. Also check for zero length.
334ad41504
This commit is contained in:
parent
55b62a937c
commit
ae01a5e9f8
@ -6393,20 +6393,14 @@ static void f_readdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
os_closedir(&dir);
|
||||
}
|
||||
|
||||
rettv->vval.v_list = tv_list_alloc(kListLenShouldKnow);
|
||||
if (rettv->vval.v_list != NULL) {
|
||||
tv_list_ref(rettv->vval.v_list);
|
||||
if (rettv->vval.v_list != NULL && ga.ga_len > 0) {
|
||||
sort_strings((char_u **)ga.ga_data, ga.ga_len);
|
||||
for (int i = 0; i < ga.ga_len; i++) {
|
||||
path = ((const char **)ga.ga_data)[i];
|
||||
tv_list_append_string(rettv->vval.v_list, path, -1);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < ga.ga_len; i++) {
|
||||
xfree(((uint8_t **)ga.ga_data)[i]);
|
||||
}
|
||||
|
||||
ga_clear(&ga);
|
||||
ga_clear_strings(&ga);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user