mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Fix memleak with repeated [gc]cm_setkey()
This commit is contained in:
@ -78,6 +78,8 @@ int ccm_init( ccm_context *ctx, cipher_id_t cipher,
|
||||
if( cipher_info->block_size != 16 )
|
||||
return( POLARSSL_ERR_CCM_BAD_INPUT );
|
||||
|
||||
cipher_free( &ctx->cipher_ctx );
|
||||
|
||||
if( ( ret = cipher_init_ctx( &ctx->cipher_ctx, cipher_info ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
|
@ -168,6 +168,8 @@ int gcm_init( gcm_context *ctx, cipher_id_t cipher, const unsigned char *key,
|
||||
if( cipher_info->block_size != 16 )
|
||||
return( POLARSSL_ERR_GCM_BAD_INPUT );
|
||||
|
||||
cipher_free( &ctx->cipher_ctx );
|
||||
|
||||
if( ( ret = cipher_init_ctx( &ctx->cipher_ctx, cipher_info ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
|
Reference in New Issue
Block a user