Improve parameter validation in mbedtls_gcm_free()
diff --git a/include/mbedtls/gcm.h b/include/mbedtls/gcm.h
index 6a49c39..cf8bed9 100644
--- a/include/mbedtls/gcm.h
+++ b/include/mbedtls/gcm.h
@@ -298,7 +298,7 @@
* 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 3e41eda..675926a 100644
--- a/library/gcm.c
+++ b/library/gcm.c
@@ -541,9 +541,8 @@
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 ) );
}