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
index 76f1125..7368ba2 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -9324,10 +9324,8 @@
}
#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 @@
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);
}
/*