Skip to content

Commit 04d50c5

Browse files
committed
fix: bunch of often occurring memory leaks, found by @ArtemRazin
Refs #2574
1 parent b92d253 commit 04d50c5

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

source/connections.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ procedure Tconnform.RefreshSessions(ParentNode: PVirtualNode);
368368
SessNode.Dummy := 0;
369369
end;
370370
end;
371+
SessionNames.Free;
371372
if not Assigned(ParentNode) then begin
372373
RefreshBackgroundColors;
373374
ListSessions.SortTree(ListSessions.Header.SortColumn, ListSessions.Header.SortDirection);
@@ -418,6 +419,7 @@ procedure Tconnform.FormShow(Sender: TObject);
418419
LastActiveSession := AppSettings.ReadString(asLastActiveSession);
419420
if (LastActiveSession = '') and (LastSessions.Count > 0) then
420421
LastActiveSession := LastSessions[0];
422+
LastSessions.Free;
421423
Node := ListSessions.GetFirst;
422424
while Assigned(Node) do begin
423425
PSess := ListSessions.GetNodeData(Node);

source/dbconnection.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11384,9 +11384,11 @@ constructor TSQLFunctionList.Create(AOwner: TDBConnection; SQLFunctionsFileOrder
1138411384
FNames.Add(SQLFunc.Name);
1138511385
end;
1138611386
Ini.Free;
11387+
Sections.Free;
1138711388
Break;
1138811389
end;
1138911390
end;
11391+
TryFiles.Free;
1139011392
end;
1139111393

1139211394

source/extra_controls.pas

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ class procedure TExtForm.RestoreListSetup( List: TLazVirtualStringTree );
158158
Regname: String;
159159
OwnerForm: TWinControl;
160160
begin
161-
ValueList := TStringList.Create;
162-
163161
// Column widths
164162
OwnerForm := GetParentFormOrFrame(List);
165163
Regname := OwnerForm.Name + '.' + List.Name;
@@ -174,6 +172,7 @@ class procedure TExtForm.RestoreListSetup( List: TLazVirtualStringTree );
174172
if (List.Header.Columns.Count > i) and (ColWidth > 0) and (ColWidth < 1000) then
175173
List.Header.Columns[i].Width := ColWidth;
176174
end;
175+
ValueList.Free;
177176
end;
178177

179178
// Column visibility
@@ -186,6 +185,7 @@ class procedure TExtForm.RestoreListSetup( List: TLazVirtualStringTree );
186185
else
187186
List.Header.Columns[i].Options := List.Header.Columns[i].Options - [coVisible];
188187
end;
188+
ValueList.Free;
189189
end;
190190

191191
// Column position
@@ -199,6 +199,7 @@ class procedure TExtForm.RestoreListSetup( List: TLazVirtualStringTree );
199199
if List.Header.Columns.Count > i then
200200
List.Header.Columns[i].Position := colpos;
201201
end;
202+
ValueList.Free;
202203
end;
203204

204205
// Sort column and direction
@@ -212,9 +213,9 @@ class procedure TExtForm.RestoreListSetup( List: TLazVirtualStringTree );
212213
else
213214
List.Header.SortDirection := sdDescending;
214215
end;
216+
ValueList.Free;
215217
end;
216218

217-
ValueList.Free;
218219
end;
219220

220221

source/table_editor.pas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ procedure TfrmTableEditor.Init(Obj: TDBObject);
446446
end else
447447
SynMemoPartitions.Clear;
448448

449+
rx.Free;
450+
449451
FColumns := DBObject.TableColumns;
450452
FKeys := DBObject.TableKeys;
451453
FForeignKeys := DBObject.TableForeignKeys;
@@ -1362,6 +1364,7 @@ procedure TfrmTableEditor.CalcMinColWidth;
13621364
ImageIndexes := GetKeyImageIndexes(FColumns[i]);
13631365
MinWidthThisCol := ImageIndexes.Count * listColumns.Images.Width;
13641366
MinWidthAllCols := Max(MinWidthAllCols, MinWidthThisCol);
1367+
ImageIndexes.Free;
13651368
end;
13661369
// Add room for text and extra spacing
13671370
Inc(MinWidthAllCols, listColumns.GetMaxColumnWidth(0));

0 commit comments

Comments
 (0)