View Issue Details

IDProjectCategoryView StatusLast Update
0036839FPCFCLpublic2020-05-02 17:57
ReporterСМ630 Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.0.4 
Fixed in Version3.3.1 
Summary0036839: TFPExpessionParser does not raise an exception when dividing by zero.
DescriptionTFPExpessionParser does not raise an exception when dividing by zero.
This way crashed cannot be handled.
Additional InformationI have edited Procedure TFPDivideOperation.GetNodeValue(var Result : TFPExpressionResult);, now the problem seems fixed.

Procedure TFPDivideOperation.GetNodeValue(var Result : TFPExpressionResult);
Var
  RRes : TFPExpressionResult;
begin
  Left.GetNodeValue(Result);
  Right.GetNodeValue(RRes);
  case Result.ResultType of
    rtInteger : if RRes.ResInteger <> 0 then Result.ResFloat:=Result.ResInteger/RRes.ResInteger else RaiseParserError(SErrDivisionByZero, [ResultTypeName(rtInteger)]);
    rtFloat : if RRes.ResFloat <> 0 then Result.ResFloat:=Result.ResFloat/RRes.ResFloat else RaiseParserError(SErrDivisionByZero, [ResultTypeName(rtFloat)]);
    rtCurrency :
        if NodeType=rtCurrency then
          if RRes.ResCurrency <> 0 then Result.ResCurrency:=Result.ResCurrency/RRes.ResCurrency else RaiseParserError(SErrDivisionByZero, [ResultTypeName(rtCurrency)])
        else
          Result.ResFloat:=Result.ResFloat/RRes.ResFloat else RaiseParserError(SErrDivisionByZero, [ResultTypeName(rtFloat)]);
  end;
  Result.ResultType:=NodeType;
end; `


Also
SErrDivisionByZero = 'Division by zero';
shall be added in Resourcestring.
TagsNo tags attached.
Fixed in Revision45223
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

Michael Van Canneyt

2020-05-02 17:57

administrator   ~0122599

Applied a patch, thanks for reporting!

Issue History

Date Modified Username Field Change
2020-03-28 16:41 СМ630 New Issue
2020-03-29 16:37 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-03-29 16:37 Michael Van Canneyt Status new => assigned
2020-05-02 17:57 Michael Van Canneyt Status assigned => resolved
2020-05-02 17:57 Michael Van Canneyt Resolution open => fixed
2020-05-02 17:57 Michael Van Canneyt Fixed in Version => 3.3.1
2020-05-02 17:57 Michael Van Canneyt Fixed in Revision => 45223
2020-05-02 17:57 Michael Van Canneyt FPCTarget => 3.2.0
2020-05-02 17:57 Michael Van Canneyt Note Added: 0122599