From fd42d531ba20f9868397711a3e67d102111c9093 Mon Sep 17 00:00:00 2001 From: k-stachowiak Date: Tue, 11 Dec 2018 14:37:51 +0100 Subject: [PATCH] Explicitly allow NULL as an argument to mbedtls_ccm_free() --- include/mbedtls/ccm.h | 4 +++- library/ccm.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/ccm.h b/include/mbedtls/ccm.h index 0eb1abe9cb..6210c1f8c4 100644 --- a/include/mbedtls/ccm.h +++ b/include/mbedtls/ccm.h @@ -109,7 +109,9 @@ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, * \brief This function releases and clears the specified CCM context * and underlying cipher sub-context. * - * \param ctx The CCM context to clear. Must not be \c NULL. + * \param ctx The CCM context to clear. + * + * \note If ctx is \c NULL, the function has no effect. */ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ); diff --git a/library/ccm.c b/library/ccm.c index 4bb3642da4..ad0d71b009 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -106,7 +106,8 @@ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, */ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) { - CCM_VALIDATE( ctx != NULL ); + if( ctx == NULL ) + return; mbedtls_cipher_free( &ctx->cipher_ctx ); mbedtls_platform_zeroize( ctx, sizeof( mbedtls_ccm_context ) ); }