Merge pull request #3426 from paul-elliott-arm/resource_leak

Fix for resource leak in test_suite_ssl
This commit is contained in:
Manuel Pégourié-Gonnard 2020-06-16 10:00:18 +02:00 committed by GitHub
commit 9dfcae8b94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1179,6 +1179,7 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
size_t keylen, maclen, ivlen; size_t keylen, maclen, ivlen;
unsigned char *key0 = NULL, *key1 = NULL; unsigned char *key0 = NULL, *key1 = NULL;
unsigned char *md0 = NULL, *md1 = NULL;
unsigned char iv_enc[16], iv_dec[16]; unsigned char iv_enc[16], iv_dec[16];
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
@ -1245,7 +1246,6 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
cipher_info->mode == MBEDTLS_MODE_STREAM ) cipher_info->mode == MBEDTLS_MODE_STREAM )
{ {
mbedtls_md_info_t const *md_info; mbedtls_md_info_t const *md_info;
unsigned char *md0, *md1;
/* Pick hash */ /* Pick hash */
md_info = mbedtls_md_info_from_type( hash_id ); md_info = mbedtls_md_info_from_type( hash_id );
@ -1283,9 +1283,6 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
memcpy( &t_out->mac_dec, md0, maclen ); memcpy( &t_out->mac_dec, md0, maclen );
} }
#endif #endif
mbedtls_free( md0 );
mbedtls_free( md1 );
} }
#else #else
((void) hash_id); ((void) hash_id);
@ -1417,6 +1414,9 @@ cleanup:
mbedtls_free( key0 ); mbedtls_free( key0 );
mbedtls_free( key1 ); mbedtls_free( key1 );
mbedtls_free( md0 );
mbedtls_free( md1 );
return( ret ); return( ret );
} }