You've already forked lazarus-ccr
fpspreadsheet: Fix integer overflow in formulas with large integer values.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8246 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -3181,7 +3181,10 @@ begin
|
|||||||
else
|
else
|
||||||
if cell^.ContentType = cctNumber then
|
if cell^.ContentType = cctNumber then
|
||||||
begin
|
begin
|
||||||
if frac(cell^.NumberValue) = 0.0 then
|
if (frac(cell^.NumberValue) = 0.0) and
|
||||||
|
(cell^.Numbervalue >= -Integer(MaxInt)-1) and
|
||||||
|
(cell^.NumberValue <= MaxInt)
|
||||||
|
then
|
||||||
Result := IntegerResult(trunc(cell^.NumberValue))
|
Result := IntegerResult(trunc(cell^.NumberValue))
|
||||||
else
|
else
|
||||||
Result := FloatResult(cell^.NumberValue);
|
Result := FloatResult(cell^.NumberValue);
|
||||||
@@ -3240,11 +3243,14 @@ begin
|
|||||||
Result := ErrorResult(errWrongType);
|
Result := ErrorResult(errWrongType);
|
||||||
end else
|
end else
|
||||||
if (cell^.ContentType = cctNumber) or (cell^.ContentType = cctDateTime) then
|
if (cell^.ContentType = cctNumber) or (cell^.ContentType = cctDateTime) then
|
||||||
begin
|
begin
|
||||||
if frac(cell^.NumberValue) = 0.0 then
|
if (frac(cell^.NumberValue) = 0.0) and
|
||||||
|
(cell^.NumberValue >= -Integer(MaxInt)-1) and
|
||||||
|
(cell^.NumberValue <= MaxInt)
|
||||||
|
then
|
||||||
Result := IntegerResult(-trunc(cell^.NumberValue))
|
Result := IntegerResult(-trunc(cell^.NumberValue))
|
||||||
else
|
else
|
||||||
Result := FloatResult(cell^.NumberValue);
|
Result := FloatResult(-cell^.NumberValue);
|
||||||
end else
|
end else
|
||||||
if (cell^.ContentType = cctBool) then
|
if (cell^.ContentType = cctBool) then
|
||||||
Result := ErrorResult(errWrongType);
|
Result := ErrorResult(errWrongType);
|
||||||
|
Reference in New Issue
Block a user