From 4b618852e4e90daaeff5fbfe7036bd11779692de Mon Sep 17 00:00:00 2001 From: Zhang Zhaolong Date: Fri, 13 Mar 2015 11:26:22 +0800 Subject: [PATCH] core/gateway: fix memory leak of packet. Signed-off-by: Zhang Zhaolong --- libfreerdp/core/gateway/tsg.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index 68d0c8819..b8b2182c8 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -731,7 +731,10 @@ BOOL TsProxyAuthorizeTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) packetResponse = (PTSG_PACKET_RESPONSE) calloc(1, sizeof(TSG_PACKET_RESPONSE)); if (!packetResponse) + { + free(packet); return FALSE; + } packet->tsgPacket.packetResponse = packetResponse; Pointer = *((UINT32*) &buffer[offset + 8]); /* PacketResponsePtr (4 bytes) */ @@ -881,7 +884,10 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) packetMsgResponse = (PTSG_PACKET_MSG_RESPONSE) calloc(1, sizeof(TSG_PACKET_MSG_RESPONSE)); if (!packetMsgResponse) + { + free(packet); return FALSE; + } packet->tsgPacket.packetMsgResponse = packetMsgResponse; Pointer = *((UINT32*) &buffer[offset + 8]); /* PacketMsgResponsePtr (4 bytes) */ @@ -896,7 +902,10 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) packetStringMessage = (PTSG_PACKET_STRING_MESSAGE) calloc(1, sizeof(TSG_PACKET_STRING_MESSAGE)); if (!packetStringMessage) - return FALSE; + { + status = FALSE; + goto out; + } packetMsgResponse->messagePacket.consentMessage = packetStringMessage; Pointer = *((UINT32*) &buffer[offset + 28]); /* ConsentMessagePtr (4 bytes) */ @@ -916,7 +925,10 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) packetStringMessage = (PTSG_PACKET_STRING_MESSAGE) calloc(1, sizeof(TSG_PACKET_STRING_MESSAGE)); if (!packetStringMessage) - return FALSE; + { + status = FALSE; + goto out; + } packetMsgResponse->messagePacket.serviceMessage = packetStringMessage; Pointer = *((UINT32*) &buffer[offset + 28]); /* ServiceMessagePtr (4 bytes) */ @@ -936,7 +948,10 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) packetReauthMessage = (PTSG_PACKET_REAUTH_MESSAGE) calloc(1, sizeof(TSG_PACKET_REAUTH_MESSAGE)); if (!packetReauthMessage) - return FALSE; + { + status = FALSE; + goto out; + } packetMsgResponse->messagePacket.reauthMessage = packetReauthMessage; Pointer = *((UINT32*) &buffer[offset + 28]); /* ReauthMessagePtr (4 bytes) */ @@ -952,6 +967,7 @@ BOOL TsProxyMakeTunnelCallReadResponse(rdpTsg* tsg, RPC_PDU* pdu) break; } +out: if (packet) { if (packet->tsgPacket.packetMsgResponse)