Stefan Oberhumer : ntdll: qsort: Check if necessary to sort.

Alexandre Julliard julliard at winehq.org
Tue Oct 5 12:03:07 CDT 2010


Module: wine
Branch: master
Commit: 38769ddfe9de03d157e03d7e82d7839cf34279c8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=38769ddfe9de03d157e03d7e82d7839cf34279c8

Author: Stefan Oberhumer <stefan at obssys.com>
Date:   Tue Oct  5 00:04:44 2010 +0200

ntdll: qsort: Check if necessary to sort.

---

 dlls/ntdll/misc.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c
index a2c08c5..9291909 100644
--- a/dlls/ntdll/misc.c
+++ b/dlls/ntdll/misc.c
@@ -294,7 +294,9 @@ NTDLL_mergesort( void *arr, void *barr, size_t elemsize, int(__cdecl *compar)(co
 void __cdecl NTDLL_qsort( void *base, size_t nmemb, size_t size,
                           int(__cdecl *compar)(const void *, const void *) )
 {
-    void *secondarr = RtlAllocateHeap (GetProcessHeap(), 0, nmemb*size);
+    void *secondarr;
+    if (nmemb < 2 || size == 0) return;
+    secondarr = RtlAllocateHeap (GetProcessHeap(), 0, nmemb*size);
     NTDLL_mergesort( base, secondarr, size, compar, 0, nmemb-1 );
     RtlFreeHeap (GetProcessHeap(),0, secondarr);
 }




More information about the wine-cvs mailing list