]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: Make key unref with NULL no-op
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 23 Aug 2019 09:27:23 +0000 (12:27 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 23 Sep 2019 05:47:49 +0000 (08:47 +0300)
src/lib-dcrypt/dcrypt-openssl.c

index 9f90e18427b58388e454c8a87bfe21bb4b359036..c420d68592860258ff953a0d87e9b95a73d1571d 100644 (file)
@@ -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;