|
@@ -667,18 +667,18 @@ var
|
|
i : integer;
|
|
i : integer;
|
|
pdest,
|
|
pdest,
|
|
psrc : Pointer;
|
|
psrc : Pointer;
|
|
- localnul : array[0..LocalThreshold-1] of byte;
|
|
|
|
|
|
+ localnul : array[0..LocalThreshold-1] of byte;
|
|
pnul : pointer;
|
|
pnul : pointer;
|
|
begin
|
|
begin
|
|
LItemSize:=FItemSize;
|
|
LItemSize:=FItemSize;
|
|
pnul:=@localnul;
|
|
pnul:=@localnul;
|
|
if LItemSize>Localthreshold then
|
|
if LItemSize>Localthreshold then
|
|
getmem(pnul,LItemSize);
|
|
getmem(pnul,LItemSize);
|
|
- fillchar(pnul^,LItemSize,#0);
|
|
|
|
|
|
+ fillchar(pnul^,LItemSize,#0);
|
|
NewCount:=0;
|
|
NewCount:=0;
|
|
psrc:=First;
|
|
psrc:=First;
|
|
pdest:=psrc;
|
|
pdest:=psrc;
|
|
-
|
|
|
|
|
|
+
|
|
For I:=0 To FCount-1 Do
|
|
For I:=0 To FCount-1 Do
|
|
begin
|
|
begin
|
|
if not CompareMem(psrc,pnul,LItemSize) then
|
|
if not CompareMem(psrc,pnul,LItemSize) then
|
|
@@ -707,7 +707,9 @@ begin
|
|
repeat
|
|
repeat
|
|
I := L;
|
|
I := L;
|
|
J := R;
|
|
J := R;
|
|
- P := (L + R) div 2;
|
|
|
|
|
|
+ { cast to dword to avoid overflow to a negative number during addition which
|
|
|
|
+ would result again in a negative number when being divided }
|
|
|
|
+ P := (dword(L) + dword(R)) div 2;
|
|
repeat
|
|
repeat
|
|
PivotItem := InternalItems[P];
|
|
PivotItem := InternalItems[P];
|
|
while Compare(PivotItem, InternalItems[I]) > 0 do
|
|
while Compare(PivotItem, InternalItems[I]) > 0 do
|