mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
Fix memory leak in GCM by adding gcm_free()
This commit is contained in:
parent
deb7949a22
commit
4fe9200f47
4 changed files with 28 additions and 0 deletions
|
|
@ -406,6 +406,12 @@ int gcm_auth_decrypt( gcm_context *ctx,
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
void gcm_free( gcm_context *ctx )
|
||||
{
|
||||
(void) cipher_free_ctx( &ctx->cipher_ctx );
|
||||
memset( ctx, 0, sizeof( gcm_context ) );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -672,6 +678,8 @@ int gcm_self_test( int verbose )
|
|||
return( 1 );
|
||||
}
|
||||
|
||||
gcm_free( &ctx );
|
||||
|
||||
if( verbose != 0 )
|
||||
printf( "passed\n" );
|
||||
|
||||
|
|
@ -696,6 +704,8 @@ int gcm_self_test( int verbose )
|
|||
return( 1 );
|
||||
}
|
||||
|
||||
gcm_free( &ctx );
|
||||
|
||||
if( verbose != 0 )
|
||||
printf( "passed\n" );
|
||||
|
||||
|
|
@ -759,6 +769,8 @@ int gcm_self_test( int verbose )
|
|||
return( 1 );
|
||||
}
|
||||
|
||||
gcm_free( &ctx );
|
||||
|
||||
if( verbose != 0 )
|
||||
printf( "passed\n" );
|
||||
|
||||
|
|
@ -822,6 +834,8 @@ int gcm_self_test( int verbose )
|
|||
return( 1 );
|
||||
}
|
||||
|
||||
gcm_free( &ctx );
|
||||
|
||||
if( verbose != 0 )
|
||||
printf( "passed\n" );
|
||||
|
||||
|
|
@ -834,6 +848,8 @@ int gcm_self_test( int verbose )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue