(trunk libT) more heap pruning: avoid an unnecessary malloc() + free() when reading PadD during an outbound encrypted handshake

This commit is contained in:
Jordan Lee 2011-04-05 21:14:44 +00:00
parent 758da07fe9
commit 4694f95594
1 changed files with 1 additions and 4 deletions

View File

@ -571,16 +571,13 @@ readPadD( tr_handshake * handshake,
struct evbuffer * inbuf )
{
const size_t needlen = handshake->pad_d_len;
uint8_t * tmp;
dbgmsg( handshake, "pad d: need %zu, got %zu",
needlen, evbuffer_get_length( inbuf ) );
if( evbuffer_get_length( inbuf ) < needlen )
return READ_LATER;
tmp = tr_new( uint8_t, needlen );
tr_peerIoReadBytes( handshake->io, inbuf, tmp, needlen );
tr_free( tmp );
tr_peerIoDrain( handshake->io, inbuf, needlen );
tr_peerIoSetEncryption( handshake->io, handshake->crypto_select );