Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2847,6 +2847,7 @@ PHP_FUNCTION(openssl_pkcs12_read)

zout = zend_try_array_init(zout);
if (!zout) {
sk_X509_pop_free(ca, X509_free);
goto cleanup;
}

Expand Down
23 changes: 23 additions & 0 deletions ext/openssl/tests/openssl_pkcs12_read_array_init.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Memory leak when array initialization in openssl_pkcs12_read() fails
--EXTENSIONS--
openssl
--FILE--
<?php
$pfx = __DIR__ . DIRECTORY_SEPARATOR . "bug74022.pfx";
$cert_store = file_get_contents($pfx);

class Typed {
public string $foo = "bar";
}

$typed = new Typed;

try {
openssl_pkcs12_read($cert_store, $typed->foo, "csos");
} catch (TypeError $e) {
echo $e::class, ": ", $e->getMessage(), "\n";
}
?>
--EXPECT--
TypeError: Cannot assign array to reference held by property Typed::$foo of type string
Loading