Code

Bugfix from Niko Tyni, find operation with wrap turned on in an empty list
authorKalle Wallin <kaw@linux.se>
Sun, 19 Dec 2004 13:04:18 +0000 (13:04 +0000)
committerKalle Wallin <kaw@linux.se>
Sun, 19 Dec 2004 13:04:18 +0000 (13:04 +0000)
resulted in an infinite loop

git-svn-id: https://svn.musicpd.org/ncmpc/trunk@2806 09075e82-0dd4-0310-85a5-a0d7c8717e4f

src/list_window.c

index b541ac708f186602d72518917bbe3861fa612b59..c6f5375a12a6c159864fc09b7b64b6d4d7ad6a74 100644 (file)
@@ -245,6 +245,8 @@ list_window_find(list_window_t *lw,
        }
       if( wrap )
        {
+         if ( i==0 ) /* empty list */
+           return 1;
          i=0; /* first item */
          screen_bell();
        }
@@ -265,6 +267,9 @@ list_window_rfind(list_window_t *lw,
   int i = lw->selected-1;
   char *label;
 
+  if ( rows == 0 )
+    return 1;
+
   while( wrap || i==lw->selected-1 )
     {
       while( i>=0 && (label=(callback) (i,&h,callback_data)) )