Fix for resource leak in test_suite_ssl
Fix for coverity bugs 349041, 349052
Allocated pointers could potentially be leaked in the case of errors.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function
index 9d16a57..f9bb520 100644
--- a/tests/suites/test_suite_ssl.function
+++ b/tests/suites/test_suite_ssl.function
@@ -1179,6 +1179,7 @@
size_t keylen, maclen, ivlen;
unsigned char *key0 = NULL, *key1 = NULL;
+ unsigned char *md0 = NULL, *md1 = NULL;
unsigned char iv_enc[16], iv_dec[16];
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
@@ -1245,7 +1246,6 @@
cipher_info->mode == MBEDTLS_MODE_STREAM )
{
mbedtls_md_info_t const *md_info;
- unsigned char *md0, *md1;
/* Pick hash */
md_info = mbedtls_md_info_from_type( hash_id );
@@ -1283,9 +1283,6 @@
memcpy( &t_out->mac_dec, md0, maclen );
}
#endif
-
- mbedtls_free( md0 );
- mbedtls_free( md1 );
}
#else
((void) hash_id);
@@ -1417,6 +1414,9 @@
mbedtls_free( key0 );
mbedtls_free( key1 );
+ mbedtls_free( md0 );
+ mbedtls_free( md1 );
+
return( ret );
}