Skip to content

Commit 6c0d559

Browse files
committed
Merge branch 'PHP-8.3'
2 parents 94ddc74 + 3c176d4 commit 6c0d559

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ext/openssl/openssl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,6 +3194,7 @@ PHP_FUNCTION(openssl_csr_sign)
31943194
X509 *cert = NULL, *new_cert = NULL;
31953195
EVP_PKEY * key = NULL, *priv_key = NULL;
31963196
int i;
3197+
bool new_cert_used = false;
31973198
struct php_x509_request req;
31983199

31993200
ZEND_PARSE_PARAMETERS_START(4, 6)
@@ -3315,11 +3316,12 @@ PHP_FUNCTION(openssl_csr_sign)
33153316
object_init_ex(return_value, php_openssl_certificate_ce);
33163317
cert_object = Z_OPENSSL_CERTIFICATE_P(return_value);
33173318
cert_object->x509 = new_cert;
3319+
new_cert_used = true;
33183320

33193321
cleanup:
33203322

3321-
if (cert == new_cert) {
3322-
cert = NULL;
3323+
if (!new_cert_used && new_cert) {
3324+
X509_free(new_cert);
33233325
}
33243326

33253327
PHP_SSL_REQ_DISPOSE(&req);
@@ -3328,7 +3330,7 @@ PHP_FUNCTION(openssl_csr_sign)
33283330
if (csr_str) {
33293331
X509_REQ_free(csr);
33303332
}
3331-
if (cert_str && cert) {
3333+
if (cert_str && cert && cert != new_cert) {
33323334
X509_free(cert);
33333335
}
33343336
}

0 commit comments

Comments
 (0)