From 3fc0d304476ce4feee06a92d856ba889fd4f5d2a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 10 Dec 2021 14:28:31 +0100 Subject: [PATCH] Don't fail until everything is initialized Can't call mbedtls_cipher_free(&invalid_ctx) in cleanup if mbedtls_cipher_init(&invalid_ctx) hasn't been called. Signed-off-by: Gilles Peskine --- tests/suites/test_suite_cipher.function | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function index b50422e39..b0b1629a8 100644 --- a/tests/suites/test_suite_cipher.function +++ b/tests/suites/test_suite_cipher.function @@ -102,9 +102,10 @@ void cipher_invalid_param_unconditional( ) (void)valid_mode; /* In some configurations this is unused */ mbedtls_cipher_init( &valid_ctx ); - TEST_ASSERT( mbedtls_cipher_setup( &valid_ctx, valid_info ) == 0 ); mbedtls_cipher_init( &invalid_ctx ); + TEST_ASSERT( mbedtls_cipher_setup( &valid_ctx, valid_info ) == 0 ); + /* mbedtls_cipher_setup() */ TEST_ASSERT( mbedtls_cipher_setup( &valid_ctx, NULL ) == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );