From f1f7b29d76ff8198d952a279e9c0a016af7198e8 Mon Sep 17 00:00:00 2001 From: gabor-mezei-arm Date: Thu, 11 Jun 2020 12:18:55 +0200 Subject: [PATCH] Fix overiding of return value. If MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED is defined, then the return value will be overridden by the extra code running after the removed return instruction. Signed-off-by: gabor-mezei-arm --- programs/ssl/ssl_server2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 1ccdeaeca..c8c52d502 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1734,6 +1734,7 @@ int main( int argc, char *argv[] ) psa_algorithm_t alg = 0; psa_key_handle_t psk_slot = 0; #endif /* MBEDTLS_USE_PSA_CRYPTO */ + int psk_free_ret = 0; unsigned char psk[MBEDTLS_PSK_MAX_LEN]; size_t psk_len = 0; psk_entry *psk_info = NULL; @@ -4301,8 +4302,8 @@ exit: sni_free( sni_info ); #endif #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) - if( ( ret = psk_free( psk_info ) ) != 0 ) - mbedtls_printf( "Failed to list of opaque PSKs - error was %d\n", ret ); + if( ( psk_free_ret = psk_free( psk_info ) ) != 0 ) + mbedtls_printf( "Failed to list of opaque PSKs - error was %d\n", psk_free_ret ); #endif #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) mbedtls_dhm_free( &dhm );