Don't sort if there's nothing to do (prevents array underflow, too). stable-2.0
authorRyan C. Gordon <icculus@icculus.org>
Thu, 07 Jun 2012 10:21:43 -0400
branchstable-2.0
changeset 1287 292f5ceaf0c0
parent 1195 d41453fa3ae0
child 1294 184697ee7a77
Don't sort if there's nothing to do (prevents array underflow, too). (transplanted from 662a7e180c480ff7731493b688aee27e8e010887)
physfs.c
--- a/physfs.c	Fri Nov 18 01:08:19 2011 -0500
+++ b/physfs.c	Thu Jun 07 10:21:43 2012 -0400
@@ -261,7 +261,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 */