Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-12

memory leak in TCustomSQLQuery.Create

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Ham

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;

---

Reply by email

Michael Van Canneyt
to Michael Van Ham
Michael Van Ham wrote 9 lines
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.

Done, thank you very much. Don't know how I could have missed that one :(

Michael.

Reply by email