Wrap calls to openssl_pkey_free in version checks, fixes #2178

This commit is contained in:
Marcus Bointon 2020-10-22 08:26:02 +02:00
parent 5ba587f4ac
commit cde7d82391
No known key found for this signature in database
GPG Key ID: DE31CD6EB646AA24
1 changed files with 6 additions and 2 deletions

View File

@ -4526,11 +4526,15 @@ class PHPMailer
$privKey = openssl_pkey_get_private($privKeyStr);
}
if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
openssl_pkey_free($privKey);
if (PHP_MAJOR_VERSION < 8) {
openssl_pkey_free($privKey);
}
return base64_encode($signature);
}
openssl_pkey_free($privKey);
if (PHP_MAJOR_VERSION < 8) {
openssl_pkey_free($privKey);
}
return '';
}