Fixed memory leaks.

This commit is contained in:
Armin Novak 2014-11-16 23:06:03 +01:00
parent 07051fb3d1
commit 585d9101b7

View File

@ -357,7 +357,7 @@ int rpc_in_write(rdpRpc* rpc, const BYTE* data, int length)
int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum) int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
{ {
BYTE* buffer; BYTE* buffer = NULL;
UINT32 offset; UINT32 offset;
rdpNtlm* ntlm; rdpNtlm* ntlm;
UINT32 stub_data_pad; UINT32 stub_data_pad;
@ -365,7 +365,7 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
SecBufferDesc Message; SecBufferDesc Message;
RpcClientCall* clientCall; RpcClientCall* clientCall;
SECURITY_STATUS encrypt_status; SECURITY_STATUS encrypt_status;
rpcconn_request_hdr_t* request_pdu; rpcconn_request_hdr_t* request_pdu = NULL;
ntlm = rpc->ntlm; ntlm = rpc->ntlm;
if (!ntlm || !ntlm->table) if (!ntlm || !ntlm->table)
@ -437,7 +437,9 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
Buffers[1].pvBuffer = calloc(1, Buffers[1].cbBuffer); Buffers[1].pvBuffer = calloc(1, Buffers[1].cbBuffer);
if (!Buffers[1].pvBuffer) if (!Buffers[1].pvBuffer)
return -1; {
goto out_free_pdu;
}
Message.cBuffers = 2; Message.cBuffers = 2;
Message.ulVersion = SECBUFFER_VERSION; Message.ulVersion = SECBUFFER_VERSION;
@ -447,8 +449,7 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
if (encrypt_status != SEC_E_OK) if (encrypt_status != SEC_E_OK)
{ {
WLog_ERR(TAG, "EncryptMessage status: 0x%08X", encrypt_status); WLog_ERR(TAG, "EncryptMessage status: 0x%08X", encrypt_status);
free(request_pdu); goto out_free_pdu;
return -1;
} }
CopyMemory(&buffer[offset], Buffers[1].pvBuffer, Buffers[1].cbBuffer); CopyMemory(&buffer[offset], Buffers[1].pvBuffer, Buffers[1].cbBuffer);
@ -458,12 +459,19 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
if (rpc_send_enqueue_pdu(rpc, buffer, request_pdu->frag_length) < 0) if (rpc_send_enqueue_pdu(rpc, buffer, request_pdu->frag_length) < 0)
length = -1; length = -1;
free (buffer);
free(request_pdu); free(request_pdu);
return length; return length;
out_free_clientCall: out_free_clientCall:
rpc_client_call_free(clientCall); rpc_client_call_free(clientCall);
out_free_pdu: out_free_pdu:
free(request_pdu); if (buffer)
free (buffer);
if (Buffers[1].pvBuffer)
free (Buffers[1].pvBuffer);
if (request_pdu)
free(request_pdu);
return -1; return -1;
} }