Clear pk context and other minor changes in *_free() procedures

This commit is contained in:
irwir 2018-06-12 18:25:09 +03:00
parent fcfa4c21c1
commit 2239a868f7
4 changed files with 29 additions and 15 deletions

View file

@ -61,10 +61,11 @@ void mbedtls_pk_init( mbedtls_pk_context *ctx )
*/
void mbedtls_pk_free( mbedtls_pk_context *ctx )
{
if( ctx == NULL || ctx->pk_info == NULL )
if( ctx == NULL )
return;
ctx->pk_info->ctx_free_func( ctx->pk_ctx );
if ( ctx->pk_info != NULL )
ctx->pk_info->ctx_free_func( ctx->pk_ctx );
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_pk_context ) );
}