[Lazarus] Dear developers... TStream.ReadAnsiString

Michael Van Canneyt michael at freepascal.org
Sat Sep 6 17:26:00 CEST 2008



On Sat, 6 Sep 2008, Osvaldo TCF - Listas wrote:

> Environment:
> Ubuntu 8.04.1
> XFCe
> FPC 2.2.3
> Lazarus r16444
> GTK2
> ----------------------------------
> Problem:
> Tstream.readansistring is not ok!
> 
> affected:
> 
> TDBImage
> Lazreport
> 
> ------------------------------------------------------------------------
> procedure TForm1.Button3Click(Sender: TObject);
> var
> st : Tstream;
> s : string;
> gc       : TGraphicClass;
> AGraphic : TGraphic;
> 
> begin
> gc := nil;
> AGraphic := nil;
> 
> st := FBDataSet.CreateBlobStream(FBDataSetIMAG_IMAGEM,bmRead); 
> s := st.ReadAnsiString;

IMHO you should never do this. 
ReadAnsiString expects the first 4 bytes to be the length of the ansistring. 
If the blob contains raw image data, then this will not give a valid string.

Michael.



More information about the Lazarus mailing list