From 5c18db7fe9195567812f7fcfe4283c430eb70f6b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 7 Jun 2012 10:21:43 -0400 Subject: [PATCH] Don't sort if there's nothing to do (prevents array underflow, too). --- src/physfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/physfs.c b/src/physfs.c index 9498a9b..f57837e 100644 --- a/src/physfs.c +++ b/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: * 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 */