Menu

#4 Dws2Exprs.pas Memory Leak

v1.2
open
nobody
5
2003-09-30
2003-09-30
No

Dws2Exprs.pas:

On TContext.Destroy, the contents of the TList object
FSubContexts are destroyed but the TList object itself
isn't..

Original code:

destructor TContext.Destroy;
var
x: Integer;
begin
for x := 0 to FSubContexts.Count - 1 do
TContext(FSubContexts[x]).Free;
inherited;
end;

Replace it with this:

destructor TContext.Destroy;
var
x: Integer;
begin
for x := 0 to FSubContexts.Count - 1 do
TContext(FSubContexts[x]).Free;
FSubContexts.Free; { this is the missing line! }
inherited;
end;

Discussion


Log in to post a comment.