Skip to content

Commit 359bb63

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix memory leak of X509_STORE in php_openssl_setup_verify() on failure
2 parents 4c5a6b0 + 87ff547 commit 359bb63

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

ext/openssl/openssl_backend_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ X509_STORE *php_openssl_setup_verify(zval *calist, uint32_t arg_num)
894894
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(calist), item) {
895895
zend_string *str = zval_try_get_string(item);
896896
if (UNEXPECTED(!str)) {
897+
X509_STORE_free(store);
897898
return NULL;
898899
}
899900

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Memory leak of X509_STORE in php_openssl_setup_verify() on failure
3+
--EXTENSIONS--
4+
openssl
5+
--FILE--
6+
<?php
7+
8+
class MyStringable{
9+
public function __toString(): string {
10+
throw new Error('stop');
11+
}
12+
}
13+
14+
try {
15+
openssl_pkcs7_verify("does not matter", 0, "does not matter", [new MyStringable]);
16+
} catch (Error $e) {
17+
echo $e->getMessage(), "\n";
18+
}
19+
20+
?>
21+
--EXPECT--
22+
stop

0 commit comments

Comments
 (0)