mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-21 11:07:51 +00:00
Fix memory leak on failure path in test code
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
008cd0c4d8
commit
40e26b2600
|
@ -185,7 +185,8 @@ int ssl_check_record( mbedtls_ssl_context const *ssl,
|
||||||
if( ret != ret_repeated )
|
if( ret != ret_repeated )
|
||||||
{
|
{
|
||||||
mbedtls_printf( "mbedtls_ssl_check_record() returned inconsistent results.\n" );
|
mbedtls_printf( "mbedtls_ssl_check_record() returned inconsistent results.\n" );
|
||||||
return( -1 );
|
ret = -1;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( ret )
|
switch( ret )
|
||||||
|
@ -196,29 +197,34 @@ int ssl_check_record( mbedtls_ssl_context const *ssl,
|
||||||
case MBEDTLS_ERR_SSL_INVALID_RECORD:
|
case MBEDTLS_ERR_SSL_INVALID_RECORD:
|
||||||
if( opt.debug_level > 1 )
|
if( opt.debug_level > 1 )
|
||||||
mbedtls_printf( "mbedtls_ssl_check_record() detected invalid record.\n" );
|
mbedtls_printf( "mbedtls_ssl_check_record() detected invalid record.\n" );
|
||||||
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MBEDTLS_ERR_SSL_INVALID_MAC:
|
case MBEDTLS_ERR_SSL_INVALID_MAC:
|
||||||
if( opt.debug_level > 1 )
|
if( opt.debug_level > 1 )
|
||||||
mbedtls_printf( "mbedtls_ssl_check_record() detected unauthentic record.\n" );
|
mbedtls_printf( "mbedtls_ssl_check_record() detected unauthentic record.\n" );
|
||||||
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MBEDTLS_ERR_SSL_UNEXPECTED_RECORD:
|
case MBEDTLS_ERR_SSL_UNEXPECTED_RECORD:
|
||||||
if( opt.debug_level > 1 )
|
if( opt.debug_level > 1 )
|
||||||
mbedtls_printf( "mbedtls_ssl_check_record() detected unexpected record.\n" );
|
mbedtls_printf( "mbedtls_ssl_check_record() detected unexpected record.\n" );
|
||||||
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mbedtls_printf( "mbedtls_ssl_check_record() failed fatally with -%#04x.\n", (unsigned int) -ret );
|
mbedtls_printf( "mbedtls_ssl_check_record() failed fatally with -%#04x.\n", (unsigned int) -ret );
|
||||||
return( -1 );
|
ret = -1;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Regardless of the outcome, forward the record to the stack. */
|
/* Regardless of the outcome, forward the record to the stack. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
mbedtls_free( tmp_buf );
|
mbedtls_free( tmp_buf );
|
||||||
|
|
||||||
return( 0 );
|
return( ret );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_SSL_RECORD_CHECKING */
|
#endif /* MBEDTLS_SSL_RECORD_CHECKING */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue