From 21298a20c4eab443694a7d34bfb1e3a5a41f01af Mon Sep 17 00:00:00 2001 From: k-stachowiak Date: Thu, 13 Dec 2018 17:11:58 +0100 Subject: [PATCH] Improve parameter validation in mbedtls_gcm_free() --- include/mbedtls/gcm.h | 2 +- library/gcm.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/mbedtls/gcm.h b/include/mbedtls/gcm.h index 6a49c39c4..cf8bed9a1 100644 --- a/include/mbedtls/gcm.h +++ b/include/mbedtls/gcm.h @@ -298,7 +298,7 @@ int mbedtls_gcm_finish( mbedtls_gcm_context *ctx, * cipher sub-context. * * \param ctx The GCM context to clear. If this is \c NULL, the call has - * no effect. + * no effect. Otherwise, this must be initialized. */ void mbedtls_gcm_free( mbedtls_gcm_context *ctx ); diff --git a/library/gcm.c b/library/gcm.c index 3e41eda9d..675926a51 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -541,9 +541,8 @@ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx, void mbedtls_gcm_free( mbedtls_gcm_context *ctx ) { - if( ctx == NULL ) { + if( ctx == NULL ) return; - } mbedtls_cipher_free( &ctx->cipher_ctx ); mbedtls_platform_zeroize( ctx, sizeof( mbedtls_gcm_context ) ); }