Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 994e866

Browse files
committed
Fix memory leak in php_openssl_pkey_from_zval()
Closes GH-16691.
1 parent 2f4f09f commit 994e866

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

‎NEWS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PHP NEWS
1111
- OpenSSL:
1212
. Prevent unexpected array entry conversion when reading key. (nielsdos)
1313
. Fix various memory leaks related to openssl exports. (nielsdos)
14+
. Fix memory leak in php_openssl_pkey_from_zval(). (nielsdos)
1415

1516
- PDO:
1617
. Fixed memory leak of `setFetchMode()`. (SakiTakamachi)

‎ext/openssl/openssl.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,6 +3533,7 @@ static EVP_PKEY *php_openssl_pkey_from_zval(
35333533
} else {
35343534
ZVAL_COPY(&tmp, zphrase);
35353535
if (!try_convert_to_string(&tmp)) {
3536+
zval_ptr_dtor(&tmp);
35363537
return NULL;
35373538
}
35383539

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
php_openssl_pkey_from_zval memory leak
3+
--EXTENSIONS--
4+
openssl
5+
--FILE--
6+
<?php
7+
8+
class StrFail {
9+
public function __toString(): string {
10+
throw new Error('create a leak');
11+
}
12+
}
13+
14+
$key = ["", new StrFail];
15+
try {
16+
openssl_pkey_export_to_file($key, "doesnotmatter");
17+
} catch (Error $e) {
18+
echo $e->getMessage(), "\n";
19+
}
20+
21+
?>
22+
--EXPECT--
23+
create a leak

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /