diff --git a/lib/dns/opensslrsa_link.c b/lib/dns/opensslrsa_link.c index fd6add864c..bdb0a3931d 100644 --- a/lib/dns/opensslrsa_link.c +++ b/lib/dns/opensslrsa_link.c @@ -1059,13 +1059,19 @@ opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { err: #if USE_EVP - if (pkey != NULL) + if (pkey != NULL) { EVP_PKEY_free(pkey); + pkey = NULL; + } #endif - if (e != NULL) + if (e != NULL) { BN_free(e); - if (rsa != NULL) + e = NULL; + } + if (rsa != NULL) { RSA_free(rsa); + rsa = NULL; + } if (cb != NULL) { BN_GENCB_free(cb); cb = NULL;