Просмотр исходного кода

Don't sort if there's nothing to do (prevents array underflow, too).
(transplanted from 662a7e180c480ff7731493b688aee27e8e010887)

Ryan C. Gordon 13 лет назад
Родитель
Сommit
fb149451b8
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      physfs.c

+ 2 - 1
physfs.c

@@ -261,7 +261,8 @@ void __PHYSFS_sort(void *entries, PHYSFS_uint32 max,
      * Quicksort w/ Bubblesort fallback algorithm inspired by code from here:
      * Quicksort w/ Bubblesort fallback algorithm inspired by code from here:
      *   http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html
      *   http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html
      */
      */
-    __PHYSFS_quick_sort(entries, 0, max - 1, cmpfn, swapfn);
+    if (max > 0)
+        __PHYSFS_quick_sort(entries, 0, max - 1, cmpfn, swapfn);
 } /* __PHYSFS_sort */
 } /* __PHYSFS_sort */