Skip to content

Commit ced518e

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fixing memory leak in openssl_pkcs12_read when zout initialisation fails (#21752)
2 parents 53d082e + 8204d4b commit ced518e

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

ext/openssl/openssl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,7 @@ PHP_FUNCTION(openssl_pkcs12_read)
15111511

15121512
zout = zend_try_array_init(zout);
15131513
if (!zout) {
1514+
sk_X509_pop_free(ca, X509_free);
15141515
goto cleanup;
15151516
}
15161517

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Memory leak when array initialization in openssl_pkcs12_read() fails
3+
--EXTENSIONS--
4+
openssl
5+
--FILE--
6+
<?php
7+
$pfx = __DIR__ . DIRECTORY_SEPARATOR . "bug74022.pfx";
8+
$cert_store = file_get_contents($pfx);
9+
10+
class Typed {
11+
public string $foo = "bar";
12+
}
13+
14+
$typed = new Typed;
15+
16+
try {
17+
openssl_pkcs12_read($cert_store, $typed->foo, "csos");
18+
} catch (TypeError $e) {
19+
echo $e::class, ": ", $e->getMessage(), "\n";
20+
}
21+
?>
22+
--EXPECT--
23+
TypeError: Cannot assign array to reference held by property Typed::$foo of type string

0 commit comments

Comments
 (0)