changeset 35215:caf85cf24a2e

Check value of n for validity before using it, not after.
author reimar
date Wed, 31 Oct 2012 19:42:13 +0000
parents 126ce1e7f87b
children 4c2104e9e0d1
files libmenu/menu_filesel.c
diffstat 1 files changed, 1 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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;