diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index d00efbfe5c2ce..90c900d136aca 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -2627,6 +2627,9 @@ PHP_FUNCTION(openssl_pkcs7_encrypt) } recipcerts = sk_X509_new_null(); + if (recipcerts == NULL) { + goto clean_exit; + } /* get certs */ if (Z_TYPE_P(zrecipcerts) == IS_ARRAY) { @@ -3241,6 +3244,9 @@ PHP_FUNCTION(openssl_cms_encrypt) } recipcerts = sk_X509_new_null(); + if (recipcerts == NULL) { + goto clean_exit; + } /* get certs */ if (Z_TYPE_P(zrecipcerts) == IS_ARRAY) { diff --git a/ext/openssl/openssl_backend_common.c b/ext/openssl/openssl_backend_common.c index 611359cccaba6..8895e58869b19 100644 --- a/ext/openssl/openssl_backend_common.c +++ b/ext/openssl/openssl_backend_common.c @@ -864,6 +864,9 @@ STACK_OF(X509) *php_openssl_array_to_X509_sk(zval * zcerts, uint32_t arg_num, co bool free_cert; sk = sk_X509_new_null(); + if (sk == NULL) { + goto clean_exit; + } /* get certs */ if (Z_TYPE_P(zcerts) == IS_ARRAY) {