* 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 -
This commit is contained in:
marco 2020-03-11 20:08:26 +00:00
parent 7b4ef925f0
commit f56e971958

View File

@ -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;