mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-05 19:35:48 +03:00
cipher: check that ctx_alloc_func is not NULL before calling it
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
@@ -263,7 +263,8 @@ int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx,
|
|||||||
|
|
||||||
memset(ctx, 0, sizeof(mbedtls_cipher_context_t));
|
memset(ctx, 0, sizeof(mbedtls_cipher_context_t));
|
||||||
|
|
||||||
if (NULL == (ctx->cipher_ctx = mbedtls_cipher_get_base(cipher_info)->ctx_alloc_func())) {
|
if ((mbedtls_cipher_get_base(cipher_info)->ctx_alloc_func != NULL) &&
|
||||||
|
(ctx->cipher_ctx = mbedtls_cipher_get_base(cipher_info)->ctx_alloc_func()) == NULL) {
|
||||||
return MBEDTLS_ERR_CIPHER_ALLOC_FAILED;
|
return MBEDTLS_ERR_CIPHER_ALLOC_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user