Indy 10 (Delphi) TIdComponent.DoWork - range check error

Giganews Newsgroups
Subject: Indy 10 (Delphi) TIdComponent.DoWork - range check error
Posted by:  Brendon Weir (brendon.we…@clear.net.nz)
Date: Mon, 13 Nov 2006

Hi,

In Indy 10 the "TIdComponent.DoWork" raises a  range check error when
"FWorkInfos[AWorkMode].Current" exceeds the
capacity of a 32 bit Integer.
This can occur if the file being transferred is over 2GB!

The "TWorkEvent" type needs to be updated to use an Int64 for the
'AWorkCount' parameter .

procedure TIdComponent.DoWork(AWorkMode: TWorkMode; const ACount: Int64);
begin
  if FWorkTarget <> nil then begin
    FWorkTarget.DoWork(AWorkMode, ACount);
  end else begin
    if FWorkInfos[AWorkMode].Level > 0 then begin
      Inc(FWorkInfos[AWorkMode].Current, ACount);
      if Assigned(OnWork) then begin
        OnWork(Self, AWorkMode, FWorkInfos[AWorkMode].Current);
      end;
    end;
  end;
end;

Regards
Brendon

Replies