Skip to content

Commit 61845cc

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix memory leaks when sk_X509_new_null() fails
2 parents 65b4073 + 7d4e430 commit 61845cc

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ext/openssl/openssl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,9 @@ PHP_FUNCTION(openssl_pkcs7_encrypt)
26272627
}
26282628

26292629
recipcerts = sk_X509_new_null();
2630+
if (recipcerts == NULL) {
2631+
goto clean_exit;
2632+
}
26302633

26312634
/* get certs */
26322635
if (Z_TYPE_P(zrecipcerts) == IS_ARRAY) {
@@ -3241,6 +3244,9 @@ PHP_FUNCTION(openssl_cms_encrypt)
32413244
}
32423245

32433246
recipcerts = sk_X509_new_null();
3247+
if (recipcerts == NULL) {
3248+
goto clean_exit;
3249+
}
32443250

32453251
/* get certs */
32463252
if (Z_TYPE_P(zrecipcerts) == IS_ARRAY) {

ext/openssl/openssl_backend_common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,9 @@ STACK_OF(X509) *php_openssl_array_to_X509_sk(zval * zcerts, uint32_t arg_num, co
864864
bool free_cert;
865865

866866
sk = sk_X509_new_null();
867+
if (sk == NULL) {
868+
goto clean_exit;
869+
}
867870

868871
/* get certs */
869872
if (Z_TYPE_P(zcerts) == IS_ARRAY) {

0 commit comments

Comments
 (0)