mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-07 15:09:28 +01:00
Fix memory leaks in example programs.
This commit is contained in:
parent
e6aef9fa70
commit
f713b0a6ce
4 changed files with 12 additions and 9 deletions
|
|
@ -67,6 +67,7 @@ int main( int argc, char *argv[] )
|
|||
unsigned char buf[512];
|
||||
const char *pers = "rsa_encrypt";
|
||||
|
||||
mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
ret = 1;
|
||||
|
||||
|
|
@ -104,8 +105,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 )
|
||||
{
|
||||
|
|
@ -160,6 +159,7 @@ int main( int argc, char *argv[] )
|
|||
exit:
|
||||
mbedtls_ctr_drbg_free( &ctr_drbg );
|
||||
mbedtls_entropy_free( &entropy );
|
||||
mbedtls_rsa_free( &rsa );
|
||||
|
||||
#if defined(_WIN32)
|
||||
mbedtls_printf( " + Press Enter to exit this program.\n" );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue