Memleak TIdFTPListOutput?

Giganews Newsgroups
Subject: Memleak TIdFTPListOutput?
Posted by:  Pascal (limagi…@telenetdotbe)
Date: Wed, 3 Dec 2008

Hi,

Using BDS2006 Indy 10 (snapshot version)

Using the default Report Memleaks on Shutdown.

Could someone please check the TDirEntry.AddSubDir function.

LDirEnt := TDirEntry.Create(APathName, ADirEnt); is created but I don't
see any freeing for this LDirEnt. The result is a lot of memleaks. When
I add FreeAndNil(LDirEnt) after AddFileName(APathName, ADirEnt) then the
memleaks are gone.

Best Regards,
Pascal

function TDirEntry.AddSubDir(const APathName: String; ADirEnt:
TIdFTPListOutputItem) : Boolean;
var
  LDirEnt : TDirEntry;
  i : Integer;
  LParentPart : String;
begin
  Result := False;
  LParentPart := StripInitPathDelim(IndyGetFilePath(APathName));
  if LParentPart = PathName then begin
    if not Assigned(FSubDirs) then begin
      FSubDirs := TIdObjectList.Create;
    end;
    LParentPart := StripInitPathDelim(IndyGetFilePath(APathName));
    LParentPart := IndyGetFileName(LParentPart);
    LDirEnt := TDirEntry.Create(APathName, ADirEnt);
    FSubDirs.Add(LDirEnt);
    AddFileName(APathName, ADirEnt);
    Result := True;
    Exit;
  end;
  if Assigned(SubDirs) then begin
    for i := 0 to SubDirs.Count-1 do begin
      LDirEnt := TDirEntry(SubDirs[i]);
      LParentPart := StripInitPathDelim(IndyGetFilePath
(LDirEnt.FDirListItem.FileName));
      //  if Copy(APathName,1, Length(LParentPart))=
      //    LParentPart then
      if TextStartsWith(APathName, LParentPart) then begin
        if LDirEnt.AddSubDir(APathName, ADirEnt) then begin
          Result := True;
          Break;
        end;
      end;
    end;
  end;
end;

Replies