AV using TWriteOnlyBlockStream

Issue #43 invalid
Former user created an issue

Hi,

I want to use the TWriteOnlyBlockStream class in order to concatenate a lot of strings, then save the result into a TStream.

I wrote the following code to do my tests :

procedure TForm2.Button1Click(Sender: TObject);
var
  WOBS: TWriteOnlyBlockStream;
  S: TMemoryStream;
  I: Integer;
begin
  WOBS := TWriteOnlyBlockStream.Create;
  try
    for I := 0 to 10 do
      WOBS.WriteString('Hello World');
    ShowMessage(WOBS.ToString); // works fine
    S := TMemoryStream.Create;
    try
      WOBS.StoreData(S); // AV
      S.SaveToFile('c:\test.txt');
    finally
      S.Free;
    end;
  finally
    WOBS.Free;
  end;
end;

Unfortunately, an AV is always raised inside StoreData(). As ToString() returns a valid string, it seems that the object is storing the data properly but fails to write its internal buffer to the stream.

Do I miss something ?

Best regards,

Adrien

Comments (1)

  1. Log in to comment