Fix memory leaks in example programs.

This commit is contained in:
Janos Follath 2016-03-17 15:21:39 +00:00 committed by Simon Butcher
parent e6aef9fa70
commit f713b0a6ce
4 changed files with 12 additions and 9 deletions

View file

@ -61,7 +61,9 @@ int main( int argc, char *argv[] )
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
char filename[512];
mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
ret = 1;
if( argc != 2 )
{
mbedtls_printf( "usage: rsa_verify <filename>\n" );
@ -83,8 +85,6 @@ int main( int argc, char *argv[] )
goto exit;
}
mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
if( ( ret = mbedtls_mpi_read_file( &rsa.N, 16, f ) ) != 0 ||
( ret = mbedtls_mpi_read_file( &rsa.E, 16, f ) ) != 0 )
{
@ -149,6 +149,8 @@ int main( int argc, char *argv[] )
exit:
mbedtls_rsa_free( &rsa );
#if defined(_WIN32)
mbedtls_printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();