From 46a101341ecb4cb800e685f5c1897ed474c4ab7b Mon Sep 17 00:00:00 2001 From: Doug Hogan Date: Mon, 7 Jan 2019 06:43:10 -0800 Subject: Revamp evp_cipher_ctx_dtor() Make it NULL safe. --- lib/crypto/c_src/cipher.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/crypto/c_src/cipher.c') diff --git a/lib/crypto/c_src/cipher.c b/lib/crypto/c_src/cipher.c index 6580cb183f..cda9b15291 100644 --- a/lib/crypto/c_src/cipher.c +++ b/lib/crypto/c_src/cipher.c @@ -74,7 +74,11 @@ static struct cipher_type_t cipher_types[] = ErlNifResourceType* evp_cipher_ctx_rtype; static void evp_cipher_ctx_dtor(ErlNifEnv* env, struct evp_cipher_ctx* ctx) { - EVP_CIPHER_CTX_free(ctx->ctx); + if (ctx == NULL) + return; + + if (ctx->ctx) + EVP_CIPHER_CTX_free(ctx->ctx); } #endif -- cgit v1.2.3