Don't sort if there's nothing to do (prevents array underflow, too).
authorRyan C. Gordon <icculus@icculus.org>
Thu, 07 Jun 2012 10:21:43 -0400
changeset 1286 662a7e180c48
parent 1285 b3750723cdf7
child 1289 5e267ff5efea
Don't sort if there's nothing to do (prevents array underflow, too).
src/physfs.c
--- a/src/physfs.c	Fri Jun 01 06:07:12 2012 -0400
+++ b/src/physfs.c	Thu Jun 07 10:21:43 2012 -0400
@@ -657,7 +657,8 @@
      * Quicksort w/ Bubblesort fallback algorithm inspired by code from here:
      *   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 */