浏览代码

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

Ryan C. Gordon 13 年之前
父节点
当前提交
5c18db7fe9
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/physfs.c

+ 2 - 1
src/physfs.c

@@ -657,7 +657,8 @@ void __PHYSFS_sort(void *entries, size_t 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 */