From e57dd2d4500c9d994dde97fc10c5eeb6e1b211db Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 25 Jun 2021 11:13:24 +0100 Subject: [PATCH] Fix potential free of uninitialised pointer A test was added in that could cause a jump to exit prior to initialisation of a pointer that would get freed if that test failed. Signed-off-by: Paul Elliott --- tests/suites/test_suite_rsa.function | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function index f5f4aacd8d..f5f515908e 100644 --- a/tests/suites/test_suite_rsa.function +++ b/tests/suites/test_suite_rsa.function @@ -179,11 +179,12 @@ void rsa_pkcs1_sign_raw( data_t * hash_result, mbedtls_test_rnd_pseudo_info rnd_info; mbedtls_rsa_init( &ctx ); - TEST_ASSERT( mbedtls_rsa_set_padding( &ctx, padding_mode, - MBEDTLS_MD_NONE ) == 0 ); mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E ); + TEST_ASSERT( mbedtls_rsa_set_padding( &ctx, padding_mode, + MBEDTLS_MD_NONE ) == 0 ); + memset( output, 0x00, sizeof( output ) ); memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );