# HG changeset patch # User aurel # Date 1122072733 0 # Node ID 261022c048cd1fb0c28c9f906c81c1bbfc6e62f9 # Parent f3a003167683a3394584bd22c40bd9ec01e06884 add some closedir() to fix some opendir() leaks diff -r f3a003167683 -r 261022c048cd libmenu/menu_filesel.c --- a/libmenu/menu_filesel.c Fri Jul 22 21:27:54 2005 +0000 +++ b/libmenu/menu_filesel.c Fri Jul 22 22:52:13 2005 +0000 @@ -177,6 +177,8 @@ } bailout: + closedir(dirp); + qsort(namelist, n, sizeof(char *), (kill_warn)compare); if (n < 0) { diff -r f3a003167683 -r 261022c048cd osdep/scandir.c --- a/osdep/scandir.c Fri Jul 22 21:27:54 2005 +0000 +++ b/osdep/scandir.c Fri Jul 22 22:52:13 2005 +0000 @@ -87,7 +87,7 @@ /* 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 @@ error: + closedir(dir); + if (namelist) { for (i = 0; i < used; i++) free(namelist[i]);