Fix memory leak in test_suite_cmac.function
diff --git a/tests/suites/test_suite_cmac.function b/tests/suites/test_suite_cmac.function
index 1f88ddc..0cb437b 100644
--- a/tests/suites/test_suite_cmac.function
+++ b/tests/suites/test_suite_cmac.function
@@ -93,6 +93,9 @@
NULL ) ==
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
+
+exit:
+ mbedtls_cipher_free( &ctx );
}
/* END_CASE */
@@ -144,6 +147,8 @@
unhexify( block4, block4_string );
unhexify( expected_result, expected_result_string );
+ mbedtls_cipher_init( &ctx );
+
/* Validate the test inputs */
TEST_ASSERT( block1_len <= 100 );
TEST_ASSERT( block2_len <= 100 );
@@ -154,8 +159,6 @@
TEST_ASSERT( ( cipher_info = mbedtls_cipher_info_from_type( cipher_type ) )
!= NULL );
- mbedtls_cipher_init( &ctx );
-
TEST_ASSERT( mbedtls_cipher_setup( &ctx, cipher_info ) == 0 );
TEST_ASSERT( mbedtls_cipher_cmac_starts( &ctx,
@@ -231,6 +234,8 @@
unhexify( expected_result_a, expected_result_a_string );
unhexify( expected_result_b, expected_result_b_string );
+ mbedtls_cipher_init( &ctx );
+
/* Validate the test inputs */
TEST_ASSERT( block_a1_len <= 100 );
TEST_ASSERT( block_a2_len <= 100 );
@@ -244,8 +249,6 @@
TEST_ASSERT( ( cipher_info = mbedtls_cipher_info_from_type( cipher_type ) )
!= NULL );
- mbedtls_cipher_init( &ctx );
-
TEST_ASSERT( mbedtls_cipher_setup( &ctx, cipher_info ) == 0 );
TEST_ASSERT( mbedtls_cipher_cmac_starts( &ctx,