Don't sort if there's nothing to do (prevents array underflow, too). stable-1.0
authorRyan C. Gordon <icculus@icculus.org>
Thu, 07 Jun 2012 10:21:43 -0400
branchstable-1.0
changeset 1288 2f4ad6a37f2e
parent 1184 dedd6ba3868f
child 1349 6c6635f53843
Don't sort if there's nothing to do (prevents array underflow, too). (transplanted from 662a7e180c480ff7731493b688aee27e8e010887)
physfs.c
--- a/physfs.c	Sat Sep 24 00:55:15 2011 -0700
+++ b/physfs.c	Thu Jun 07 10:21:43 2012 -0400
@@ -230,7 +230,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 */