Re: function ToBytes(Short) @ IdGlobal.pas is wrong.

Giganews Newsgroups
Subject: Re: function ToBytes(Short) @ IdGlobal.pas is wrong.
Posted by:  Ben Taylor [Team Indy] (to_b…@yahoo.com)
Date: Wed, 29 Jun 2005

this was fixed a while ago, try a nightly snapshot if you want

Flier Lu wrote:
> indy 10.0.52, System\IdGlobal.pas, line 2395
>
> function ToBytes(const AValue: Short): TIdBytes; overload;
> begin
>  {$IFDEF DotNet}
>  Result := System.BitConverter.GetBytes(AValue);
>  {$ELSE}
>  SetLength(Result, SizeOf(Shortint));
>  PShortint(@Result[0])^ := AValue;
>  {$ENDIF}
> end;
>
> this function is wrong, because 'short' is not 'shortint', the line
>
> SetLength(Result, SizeOf(Shortint));
> PShortint(@Result[0])^ := AValue;
>
> should be
>
> SetLength(Result, SizeOf(Short));
> PShort(@Result[0])^ := AValue;
>
> waste lots of time to locate this :S

Replies

None

In response to

function ToBytes(Short) @ IdGlobal.pas is wrong. posted by Flier Lu on Tue, 28 Jun 2005