[fpc-pascal] memory leak in TCustomSQLQuery.Create

Michael Van Ham michael.vanham at gmail.com
Tue Dec 30 05:38:41 CET 2014


Hello,

In TCustomSQLQuery.Create, FRefreshSQL:TStringList is created on line 2095,
but never freed. This causes a small memory leak.

Please see the attached test program demonstrating the issue.

Reported on the bugtracker here:
http://bugs.freepascal.org/view.php?id=27220

Please review the attached patch, and apply if suitable.

Thanks.

---

program project1;

uses
  heaptrc, SQLdb, DB;

var
  FQuery : TSQLQuery;

begin
  FQuery := TSQLQuery.create(nil);
  FQuery.Free;

end.

---

Index: sqldb.pp
===================================================================
--- sqldb.pp (revision 29360)
+++ sqldb.pp (working copy)
@@ -2118,6 +2118,7 @@
   FreeAndNil(FInsertSQL);
   FreeAndNil(FDeleteSQL);
   FreeAndNil(FUpdateSQL);
+  FreeAndNil(FRefreshSQL);
   FServerIndexDefs.Free;
   inherited Destroy;
 end;

---
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20141229/37c28f47/attachment.html>


More information about the fpc-pascal mailing list