Cleaned up location of init and free for some programs to prevent memory

leaks on incorrect arguments
This commit is contained in:
Paul Bakker
2014-04-17 16:02:36 +02:00
parent 993f02cda0
commit 3914840d78
13 changed files with 51 additions and 30 deletions

View File

@@ -172,7 +172,11 @@ static int ssl_test( struct options *opt )
ret = 1;
memset( &ssl, 0, sizeof(ssl_context) );
entropy_init( &entropy );
memset( &srvcert, 0, sizeof( x509_cert ) );
memset( &rsa, 0, sizeof( rsa_context ) );
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
(const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
@@ -186,9 +190,6 @@ static int ssl_test( struct options *opt )
memset( read_state, 0, sizeof( read_state ) );
memset( write_state, 0, sizeof( write_state ) );
memset( &srvcert, 0, sizeof( x509_cert ) );
memset( &rsa, 0, sizeof( rsa_context ) );
if( opt->opmode == OPMODE_CLIENT )
{
if( ( ret = net_connect( &client_fd, opt->server_name,
@@ -201,7 +202,7 @@ static int ssl_test( struct options *opt )
if( ( ret = ssl_init( &ssl ) ) != 0 )
{
printf( " ! ssl_init returned %d\n\n", ret );
return( ret );
goto exit;
}
ssl_set_endpoint( &ssl, SSL_IS_CLIENT );
@@ -408,7 +409,9 @@ exit:
x509_free( &srvcert );
rsa_free( &rsa );
ssl_free( &ssl );
net_close( client_fd );
if( client_fd != -1 )
net_close( client_fd );
return( ret );
}