From: Aki Tuomi Date: Fri, 23 Aug 2019 09:27:23 +0000 (+0300) Subject: lib-dcrypt: Make key unref with NULL no-op X-Git-Tag: 2.3.8~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3374a5ae4d261c471929fe9ca4b0db124b14b896;p=thirdparty%2Fdovecot%2Fcore.git lib-dcrypt: Make key unref with NULL no-op --- diff --git a/src/lib-dcrypt/dcrypt-openssl.c b/src/lib-dcrypt/dcrypt-openssl.c index 9f90e18427..c420d68592 100644 --- a/src/lib-dcrypt/dcrypt-openssl.c +++ b/src/lib-dcrypt/dcrypt-openssl.c @@ -2182,8 +2182,10 @@ static void dcrypt_openssl_ref_private_key(struct dcrypt_private_key *key) static void dcrypt_openssl_unref_public_key(struct dcrypt_public_key **key) { - i_assert(key != NULL && *key != NULL); + i_assert(key != NULL); struct dcrypt_public_key *_key = *key; + if (_key == NULL) + return; i_assert(_key->ref > 0); *key = NULL; if (--_key->ref > 0) return; @@ -2193,8 +2195,10 @@ static void dcrypt_openssl_unref_public_key(struct dcrypt_public_key **key) static void dcrypt_openssl_unref_private_key(struct dcrypt_private_key **key) { - i_assert(key != NULL && *key != NULL); + i_assert(key != NULL); struct dcrypt_private_key *_key = *key; + if (_key == NULL) + return; i_assert(_key->ref > 0); *key = NULL; if (--_key->ref > 0) return;