You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2012/03/22 03:40:45 UTC
svn commit: r1303637 - in /thrift/trunk/lib/delphi/src: Thrift.Protocol.pas
Thrift.Transport.pas
Author: jfarrell
Date: Thu Mar 22 02:40:45 2012
New Revision: 1303637
URL: http://svn.apache.org/viewvc?rev=1303637&view=rev
Log:
THRIFT-1537:TFramedTransport issues
Client: delphi
Patch: Jens Geyer
TFramedTransport fixes for:
- The offset "off" is ignored, instead always 0 is used fpor reads and writes
- Trying to write an empty byte array results in range check exceptions
Modified:
thrift/trunk/lib/delphi/src/Thrift.Protocol.pas
thrift/trunk/lib/delphi/src/Thrift.Transport.pas
Modified: thrift/trunk/lib/delphi/src/Thrift.Protocol.pas
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/delphi/src/Thrift.Protocol.pas?rev=1303637&r1=1303636&r2=1303637&view=diff
==============================================================================
--- thrift/trunk/lib/delphi/src/Thrift.Protocol.pas (original)
+++ thrift/trunk/lib/delphi/src/Thrift.Protocol.pas Thu Mar 22 02:40:45 2012
@@ -972,9 +972,11 @@ begin
end;
procedure TBinaryProtocolImpl.WriteBinary( const b: TBytes);
+var iLen : Integer;
begin
- WriteI32( Length(b));
- FTrans.Write(b, 0, Length( b));
+ iLen := Length(b);
+ WriteI32( iLen);
+ if iLen > 0 then FTrans.Write(b, 0, iLen);
end;
procedure TBinaryProtocolImpl.WriteBool(b: Boolean);
Modified: thrift/trunk/lib/delphi/src/Thrift.Transport.pas
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/delphi/src/Thrift.Transport.pas?rev=1303637&r1=1303636&r2=1303637&view=diff
==============================================================================
--- thrift/trunk/lib/delphi/src/Thrift.Transport.pas (original)
+++ thrift/trunk/lib/delphi/src/Thrift.Transport.pas Thu Mar 22 02:40:45 2012
@@ -1136,7 +1136,9 @@ var
begin
if FReadBuffer <> nil then
begin
- got := FReadBuffer.Read( Pointer(@buf[0])^, len );
+ if len > 0
+ then got := FReadBuffer.Read( Pointer(@buf[off])^, len )
+ else got := 0;
if got > 0 then
begin
Result := got;
@@ -1145,7 +1147,9 @@ begin
end;
ReadFrame;
- Result := FReadBuffer.Read( Pointer(@buf[0])^, len );
+ if len > 0
+ then Result := FReadBuffer.Read( Pointer(@buf[off])^, len)
+ else Result := 0;
end;
procedure TFramedTransportImpl.ReadFrame;
@@ -1171,7 +1175,8 @@ end;
procedure TFramedTransportImpl.Write(const buf: TBytes; off, len: Integer);
begin
- FWriteBuffer.Write( Pointer(@buf[0])^, len );
+ if len > 0
+ then FWriteBuffer.Write( Pointer(@buf[off])^, len );
end;
{ TFramedTransport.TFactory }