libfreerdp-core: fix memory leaks and double free

This commit is contained in:
Jay Sorg 2012-02-10 12:35:22 -08:00 committed by atong
parent 8e627212a0
commit 45e5f5e713
3 changed files with 14 additions and 1 deletions

View File

@ -107,6 +107,8 @@ void crypto_des3_decrypt(CryptoDes3 des3, uint32 length, const uint8* in_data, u
void crypto_des3_free(CryptoDes3 des3)
{
if (des3 == NULL)
return;
EVP_CIPHER_CTX_cleanup(&des3->des3_ctx);
xfree(des3);
}
@ -135,6 +137,8 @@ void crypto_hmac_final(CryptoHmac hmac, uint8* out_data, uint32 length)
void crypto_hmac_free(CryptoHmac hmac)
{
if (hmac == NULL)
return;
HMAC_CTX_cleanup(&hmac->hmac_ctx);
xfree(hmac);
}
@ -149,6 +153,8 @@ CryptoCert crypto_cert_read(uint8* data, uint32 length)
void crypto_cert_free(CryptoCert cert)
{
if (cert == NULL)
return;
X509_free(cert->px509);
xfree(cert);
}

View File

@ -192,11 +192,13 @@ void freerdp_context_new(freerdp* instance)
void freerdp_context_free(freerdp* instance)
{
if (instance->context == NULL)
return;
IFCALL(instance->ContextFree, instance, instance->context);
rdp_free(instance->context->rdp);
graphics_free(instance->context->graphics);
xfree(instance->context);
instance->context = NULL;
}
uint32 freerdp_error_info(freerdp* instance)

View File

@ -902,6 +902,11 @@ void rdp_free(rdpRdp* rdp)
{
if (rdp != NULL)
{
crypto_rc4_free(rdp->rc4_decrypt_key);
crypto_rc4_free(rdp->rc4_encrypt_key);
crypto_des3_free(rdp->fips_encrypt);
crypto_des3_free(rdp->fips_decrypt);
crypto_hmac_free(rdp->fips_hmac);
extension_free(rdp->extension);
settings_free(rdp->settings);
transport_free(rdp->transport);