mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix memory leak of X509_STORE in php_openssl_setup_verify() on failure
This commit is contained in:
@@ -894,6 +894,7 @@ X509_STORE *php_openssl_setup_verify(zval *calist, uint32_t arg_num)
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(calist), item) {
|
||||
zend_string *str = zval_try_get_string(item);
|
||||
if (UNEXPECTED(!str)) {
|
||||
X509_STORE_free(store);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
22
ext/openssl/tests/memory_leak_x509_store.phpt
Normal file
22
ext/openssl/tests/memory_leak_x509_store.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Memory leak of X509_STORE in php_openssl_setup_verify() on failure
|
||||
--EXTENSIONS--
|
||||
openssl
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class MyStringable{
|
||||
public function __toString(): string {
|
||||
throw new Error('stop');
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
openssl_pkcs7_verify("does not matter", 0, "does not matter", [new MyStringable]);
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
stop
|
||||
Reference in New Issue
Block a user