Browse Source

* Fixed memory leak

git-svn-id: trunk@21933 -
michael 13 years ago
parent
commit
f6662b7f3c
1 changed files with 6 additions and 1 deletions
  1. 6 1
      packages/fcl-passrc/src/pastree.pp

+ 6 - 1
packages/fcl-passrc/src/pastree.pp

@@ -2668,6 +2668,8 @@ end;
 destructor TProcedureBody.Destroy;
 begin
   FreeAndNil(Labels);
+  if Assigned(Body) then
+    Body.Release;
   inherited Destroy;
 end;
 
@@ -2684,7 +2686,10 @@ procedure TPasImplWhileDo.AddElement(Element: TPasImplElement);
 begin
   inherited AddElement(Element);
   if Body=nil then
-    Body:=Element
+    begin
+    Body:=Element;
+    Body.AddRef;
+    end
   else
     raise Exception.Create('TPasImplWhileDo.AddElement body already set - please report this bug');
 end;