Use ASSERT_ALLOC

Change the calloc functions to ASSERT_ALLOC to check the
return value of calloc as well.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
Gabor Mezei 2022-02-07 18:21:39 +01:00
parent 89c1a95f8f
commit 298a2d6109
No known key found for this signature in database
GPG key ID: 106F5A41ECC305BD
2 changed files with 4 additions and 4 deletions

View file

@ -44,7 +44,7 @@ void test_hkdf_extract( int md_alg, char *hex_ikm_string,
TEST_ASSERT( md != NULL );
output_prk_len = mbedtls_md_get_size( md );
output_prk = mbedtls_calloc( 1, output_prk_len );
ASSERT_ALLOC( output_prk, output_prk_len );
ikm = mbedtls_test_unhexify_alloc( hex_ikm_string, &ikm_len );
salt = mbedtls_test_unhexify_alloc( hex_salt_string, &salt_len );
@ -113,7 +113,7 @@ void test_hkdf_extract_ret( int hash_len, int ret )
fake_md_info.type = MBEDTLS_MD_NONE;
fake_md_info.size = hash_len;
prk = mbedtls_calloc( MBEDTLS_MD_MAX_SIZE, 1 );
ASSERT_ALLOC( prk, MBEDTLS_MD_MAX_SIZE);
salt_len = 0;
ikm_len = 0;

View file

@ -3817,7 +3817,7 @@ void psa_hkdf_extract( int alg, char *hex_ikm_string,
size_t ikm_len, salt_len, prk_len, output_prk_size, output_prk_len;
output_prk_size = PSA_HASH_LENGTH( alg );
output_prk = mbedtls_calloc( 1, output_prk_size );
ASSERT_ALLOC( output_prk, output_prk_size );
ikm = mbedtls_test_unhexify_alloc( hex_ikm_string, &ikm_len );
salt = mbedtls_test_unhexify_alloc( hex_salt_string, &salt_len );
@ -3850,8 +3850,8 @@ void psa_hkdf_extract_ret( int hash_len, int ret )
unsigned char *prk = NULL;
size_t salt_len, ikm_len, prk_len;
prk = mbedtls_calloc( PSA_MAC_MAX_SIZE, 1 );
salt_len = hash_len;
ASSERT_ALLOC( prk, PSA_MAC_MAX_SIZE);
ikm_len = 0;
prk_len = 0;