diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c index 4dd2d69e8b..9930188c42 100644 --- a/libmenu/menu_filesel.c +++ b/libmenu/menu_filesel.c @@ -177,6 +177,8 @@ static int open_dir(menu_t* menu,char* args) { } bailout: + closedir(dirp); + qsort(namelist, n, sizeof(char *), (kill_warn)compare); if (n < 0) { diff --git a/osdep/scandir.c b/osdep/scandir.c index 868dd7cb57..46bb6b117a 100644 --- a/osdep/scandir.c +++ b/osdep/scandir.c @@ -87,7 +87,7 @@ scandir(const char *dirname, /* duplicate struct direct for this entry */ len = offsetof(struct dirent, d_name) + strlen(ent->d_name) + 1; if ((ent2 = malloc(len)) == NULL) - return -1; + goto error; if (used >= allocated) { allocated *= 2; @@ -109,6 +109,8 @@ scandir(const char *dirname, error: + closedir(dir); + if (namelist) { for (i = 0; i < used; i++) free(namelist[i]);