View Issue Details

IDProjectCategoryView StatusLast Update
0032626FPCRTLpublic2017-12-29 21:59
ReporterMattias GaertnerAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.1.1Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0032626: TReader does not free component on error
DescriptionTReader contains function Recover, which has a parameter 'Component' with same name as enclosing function parameter. This way the IF checks the wrong 'Component'.
Attached patch fixes this.
TagsNo tags attached.
Fixed in Revision37851
FPCOldBugId0
FPCTarget
Attached Files
  • p.patch (743 bytes)
    Index: rtl/objpas/classes/reader.inc
    ===================================================================
    --- rtl/objpas/classes/reader.inc	(revision 37527)
    +++ rtl/objpas/classes/reader.inc	(working copy)
    @@ -850,14 +850,14 @@
     var
       Flags: TFilerFlags;
     
    -  function Recover(var Component: TComponent): Boolean;
    +  function Recover(var CurComponent: TComponent): Boolean;
       begin
         Result := False;
         if ExceptObject.InheritsFrom(Exception) then
         begin
           if not ((ffInherited in Flags) or Assigned(Component)) then
    -        Component.Free;
    -      Component := nil;
    +        CurComponent.Free;
    +      CurComponent := nil;
           FDriver.SkipComponent(False);
           Result := Error(Exception(ExceptObject).Message);
         end;
    
    p.patch (743 bytes)

Activities

Mattias Gaertner

2017-10-29 16:29

manager  

p.patch (743 bytes)
Index: rtl/objpas/classes/reader.inc
===================================================================
--- rtl/objpas/classes/reader.inc	(revision 37527)
+++ rtl/objpas/classes/reader.inc	(working copy)
@@ -850,14 +850,14 @@
 var
   Flags: TFilerFlags;
 
-  function Recover(var Component: TComponent): Boolean;
+  function Recover(var CurComponent: TComponent): Boolean;
   begin
     Result := False;
     if ExceptObject.InheritsFrom(Exception) then
     begin
       if not ((ffInherited in Flags) or Assigned(Component)) then
-        Component.Free;
-      Component := nil;
+        CurComponent.Free;
+      CurComponent := nil;
       FDriver.SkipComponent(False);
       Result := Error(Exception(ExceptObject).Message);
     end;
p.patch (743 bytes)

Michael Van Canneyt

2017-12-29 10:38

administrator   ~0105093

Applied, thank you very much!

Mattias Gaertner

2017-12-29 21:59

manager   ~0105123

Thanks!

Issue History

Date Modified Username Field Change
2017-10-29 16:29 Mattias Gaertner New Issue
2017-10-29 16:29 Mattias Gaertner File Added: p.patch
2017-10-29 17:10 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-10-29 17:10 Michael Van Canneyt Status new => assigned
2017-12-29 10:38 Michael Van Canneyt Fixed in Revision => 37851
2017-12-29 10:38 Michael Van Canneyt Note Added: 0105093
2017-12-29 10:38 Michael Van Canneyt Status assigned => resolved
2017-12-29 10:38 Michael Van Canneyt Fixed in Version => 3.1.1
2017-12-29 10:38 Michael Van Canneyt Resolution open => fixed
2017-12-29 10:38 Michael Van Canneyt Target Version => 3.2.0
2017-12-29 21:59 Mattias Gaertner Note Added: 0105123
2017-12-29 21:59 Mattias Gaertner Status resolved => closed