mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Fix memory leak in php_openssl_pkey_from_zval()
Closes GH-16691.
This commit is contained in:
parent
2f4f09f7e6
commit
994e866cf2
3 changed files with 25 additions and 0 deletions
1
NEWS
1
NEWS
|
@ -11,6 +11,7 @@ PHP NEWS
|
||||||
- OpenSSL:
|
- OpenSSL:
|
||||||
. Prevent unexpected array entry conversion when reading key. (nielsdos)
|
. Prevent unexpected array entry conversion when reading key. (nielsdos)
|
||||||
. Fix various memory leaks related to openssl exports. (nielsdos)
|
. Fix various memory leaks related to openssl exports. (nielsdos)
|
||||||
|
. Fix memory leak in php_openssl_pkey_from_zval(). (nielsdos)
|
||||||
|
|
||||||
- PDO:
|
- PDO:
|
||||||
. Fixed memory leak of `setFetchMode()`. (SakiTakamachi)
|
. Fixed memory leak of `setFetchMode()`. (SakiTakamachi)
|
||||||
|
|
|
@ -3533,6 +3533,7 @@ static EVP_PKEY *php_openssl_pkey_from_zval(
|
||||||
} else {
|
} else {
|
||||||
ZVAL_COPY(&tmp, zphrase);
|
ZVAL_COPY(&tmp, zphrase);
|
||||||
if (!try_convert_to_string(&tmp)) {
|
if (!try_convert_to_string(&tmp)) {
|
||||||
|
zval_ptr_dtor(&tmp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
ext/openssl/tests/php_openssl_pkey_from_zval_leak.phpt
Normal file
23
ext/openssl/tests/php_openssl_pkey_from_zval_leak.phpt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
--TEST--
|
||||||
|
php_openssl_pkey_from_zval memory leak
|
||||||
|
--EXTENSIONS--
|
||||||
|
openssl
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class StrFail {
|
||||||
|
public function __toString(): string {
|
||||||
|
throw new Error('create a leak');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = ["", new StrFail];
|
||||||
|
try {
|
||||||
|
openssl_pkey_export_to_file($key, "doesnotmatter");
|
||||||
|
} catch (Error $e) {
|
||||||
|
echo $e->getMessage(), "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
create a leak
|
Loading…
Add table
Add a link
Reference in a new issue