[fpc-devel] memleak in pascal parser

Vincent Snijders vincent.snijders at gmail.com
Fri Nov 5 17:07:48 CET 2010


Hi,

I am trying to fix the memleaks in fpdoc. Attached is a patch for
pascal parser package.

There are still more leaks, but that is for another time.

Vincent
-------------- next part --------------
Index: packages/fcl-passrc/src/pastree.pp
===================================================================
--- packages/fcl-passrc/src/pastree.pp	(revision 16301)
+++ packages/fcl-passrc/src/pastree.pp	(working copy)
@@ -1440,6 +1440,8 @@
     (e.g. in Constants) }
   if Assigned(VarType) then
     VarType.Release;
+  if Assigned(Expr) then
+    Expr.Release;
   inherited Destroy;
 end;
 
Index: packages/fcl-passrc/src/pparser.pp
===================================================================
--- packages/fcl-passrc/src/pparser.pp	(revision 16301)
+++ packages/fcl-passrc/src/pparser.pp	(working copy)
@@ -3093,16 +3093,15 @@
       begin
         Variant := TPasVariant(CreateElement(TPasVariant, '', Parent));
         Parent.Variants.Add(Variant);
-        Variant.Values := TStringList.Create;
         while True do
         begin
-      Variant.Values.Add(ParseExpression(Parent));
-      NextToken;
-      if CurToken = tkColon then
-        break
-      else if CurToken <> tkComma then
-        ParseExc(SParserExpectedCommaColon);
-    end;
+          Variant.Values.Add(ParseExpression(Parent));
+          NextToken;
+          if CurToken = tkColon then
+            break
+          else if CurToken <> tkComma then
+            ParseExc(SParserExpectedCommaColon);
+        end;
         ExpectToken(tkBraceOpen);
     Variant.Members := TPasRecordType(CreateElement(TPasRecordType, '',
       Variant));


More information about the fpc-devel mailing list