Selaa lähdekoodia

* fix for bug #36722. Assigning result of compare(w)str to shortint risks overflow if length difference>=128.

Add sign() calls to fix this.

git-svn-id: trunk@44290 -
marco 5 vuotta sitten
vanhempi
sitoutus
f56e971958
1 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 4 4
      packages/rtl-objpas/src/inc/variants.pp

+ 4 - 4
packages/rtl-objpas/src/inc/variants.pp

@@ -1183,10 +1183,10 @@ begin
   if OpCode in [opCmpEq, opCmpNe] then
     if Length(WideString(Left)) <> Length(WideString(Right)) then
       Exit(-1);
-  Result := WideCompareStr(
+  Result := sign(WideCompareStr(
     WideString(Left),
     WideString(Right)
-  );
+  ));
 end;
 
 
@@ -1204,10 +1204,10 @@ begin
   if OpCode in [opCmpEq, opCmpNe] then
     if Length(AnsiString(Left)) <> Length(AnsiString(Right)) then
       Exit(-1);
-  Result := CompareStr(
+  Result := sign(CompareStr(
     AnsiString(Left),
     AnsiString(Right)
-  );
+  ));
 end;