# HG changeset patch # User reimar # Date 1351712533 0 # Node ID caf85cf24a2e69ca82869e0d8706fc9f0ca62c01 # Parent 126ce1e7f87b7cacdb65e8bc580a862c73e917f3 Check value of n for validity before using it, not after. diff -r 126ce1e7f87b -r caf85cf24a2e libmenu/menu_filesel.c --- a/libmenu/menu_filesel.c Wed Oct 31 19:08:19 2012 +0000 +++ b/libmenu/menu_filesel.c Wed Oct 31 19:42:13 2012 +0000 @@ -313,12 +313,11 @@ free_extensions (extensions); closedir(dirp); - qsort(namelist, n, sizeof(char *), (kill_warn)compare); - if (n < 0) { mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ReaddirError,strerror(errno)); return 0; } + qsort(namelist, n, sizeof(char *), (kill_warn)compare); while(n--) { if((e = calloc(1,sizeof(list_entry_t))) != NULL){ e->p.next = NULL;