Permalink
Browse files

Merge pull request #14 from rf232/patch-1

Fix Integer Over/Underflow in DynArrayCompareInteger
  • Loading branch information...
2 parents ad1d1c8 + 31bce47 commit 10776ede92b0b13a4fd15cc4fa63cd93d001c3d9 @ahausladen ahausladen committed Apr 30, 2014
Showing with 7 additions and 1 deletion.
  1. +7 −1 jcl/source/common/JclSysUtils.pas
@@ -1581,7 +1581,13 @@ function DynArrayCompareSmallInt(Item1, Item2: Pointer): Integer;
function DynArrayCompareInteger(Item1, Item2: Pointer): Integer;
begin
- Result := PInteger(Item1)^ - PInteger(Item2)^;
+ if PInteger(Item1)^ < PInteger(Item2)^ then
+ Result := -1
+ else
+ if PInteger(Item1)^ > PInteger(Item2)^ then
+ Result := 1
+ else
+ Result := 0;
end;
function DynArrayCompareCardinal(Item1, Item2: Pointer): Integer;

0 comments on commit 10776ed

Please sign in to comment.