View Issue Details

IDProjectCategoryView StatusLast Update
0032446FPCFCLpublic2017-09-20 16:51
ReporterPetr-KAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformindependentOSOS Version
Product Version3.1.1Product BuildRevision: 36503 
Target Version3.2.0Fixed in Version3.1.1 
Summary0032446: Bad exception handling in TFloatField.SetAsString
Descriptiontry
  f := StrToFloat(AValue);
  SetAsFloat(f); <- exception here is hidden by "not valid float"
except
  DatabaseErrorFmt(SNotAFloat, [AValue]);
end;

SetAsFloat should be outside of try except.
Patch is included.
TagsNo tags attached.
Fixed in Revision37267
FPCOldBugId
FPCTarget
Attached Files
  • fields.patch (539 bytes)
    Index: packages/fcl-db/src/base/fields.inc
    ===================================================================
    --- packages/fcl-db/src/base/fields.inc	(revision 36503)
    +++ packages/fcl-db/src/base/fields.inc	(working copy)
    @@ -2070,13 +2070,14 @@
     begin
       If (AValue='') then
         Clear
    -  else  
    +  else begin
         try
           f := StrToFloat(AValue);
    -      SetAsFloat(f);
         except
           DatabaseErrorFmt(SNotAFloat, [AValue]);
         end;
    +    SetAsFloat(f);
    +  end;
     end;
     
     procedure TFloatField.SetVarValue(const AValue: Variant);
    
    fields.patch (539 bytes)

Activities

Petr-K

2017-09-20 09:25

reporter  

fields.patch (539 bytes)
Index: packages/fcl-db/src/base/fields.inc
===================================================================
--- packages/fcl-db/src/base/fields.inc	(revision 36503)
+++ packages/fcl-db/src/base/fields.inc	(working copy)
@@ -2070,13 +2070,14 @@
 begin
   If (AValue='') then
     Clear
-  else  
+  else begin
     try
       f := StrToFloat(AValue);
-      SetAsFloat(f);
     except
       DatabaseErrorFmt(SNotAFloat, [AValue]);
     end;
+    SetAsFloat(f);
+  end;
 end;
 
 procedure TFloatField.SetVarValue(const AValue: Variant);
fields.patch (539 bytes)

Michael Van Canneyt

2017-09-20 16:00

administrator   ~0102943

I have fixed this slightly different.
Thanks for reporting and for the patch.

Petr-K

2017-09-20 16:51

reporter   ~0102948

works fine

Issue History

Date Modified Username Field Change
2017-09-20 09:25 Petr-K New Issue
2017-09-20 09:25 Petr-K File Added: fields.patch
2017-09-20 16:00 Michael Van Canneyt Fixed in Revision => 37267
2017-09-20 16:00 Michael Van Canneyt Note Added: 0102943
2017-09-20 16:00 Michael Van Canneyt Status new => resolved
2017-09-20 16:00 Michael Van Canneyt Fixed in Version => 3.1.1
2017-09-20 16:00 Michael Van Canneyt Resolution open => fixed
2017-09-20 16:00 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-09-20 16:00 Michael Van Canneyt Target Version => 3.2.0
2017-09-20 16:51 Petr-K Note Added: 0102948
2017-09-20 16:51 Petr-K Status resolved => closed