Skip to content

Commit 16a8a60

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79145: openssl memory leak
2 parents b0f8d38 + 9eff906 commit 16a8a60

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ PHP NEWS
2424
. Fixed #79114 (Eval class during preload causes class to be only half
2525
available). (Laruence)
2626

27+
- OpenSSL:
28+
. Fixed bug #79145 (openssl memory leak). (cmb, Nikita)
29+
2730
- Reflection:
2831
. Fixed bug #79115 (ReflectionClass::isCloneable call reflected class
2932
__destruct). (Nikita)

ext/openssl/openssl.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4767,7 +4767,6 @@ PHP_FUNCTION(openssl_pkey_get_public)
47674767
RETURN_FALSE;
47684768
}
47694769
ZVAL_RES(return_value, res);
4770-
Z_ADDREF_P(return_value);
47714770
}
47724771
/* }}} */
47734772

@@ -4809,7 +4808,6 @@ PHP_FUNCTION(openssl_pkey_get_private)
48094808
RETURN_FALSE;
48104809
}
48114810
ZVAL_RES(return_value, res);
4812-
Z_ADDREF_P(return_value);
48134811
}
48144812

48154813
/* }}} */

ext/openssl/tests/bug79145.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #79145 (openssl memory leak)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('openssl')) die('skip openssl extension not available');
6+
if (getenv('SKIP_SLOW_TESTS')) die('skip slow test');
7+
?>
8+
--FILE--
9+
<?php
10+
$b = '-----BEGIN PUBLIC KEY-----
11+
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDaFhc31WeskqxwI+Si5R/fZrLK
12+
pJOlABiI3RZfKCHJVrXl3IvcHDFM/BHKUJoSi/ee8GS9iw0G4Z1eCzJdthXxHARh
13+
j85Q5OliVxOdB1LoTOsOmfFf/fdvpU3DsOWsDKlVrL41MHxXorwrwOiys/r/gv2d
14+
C9C4JmhTOjBVAK8SewIDAQAC
15+
-----END PUBLIC KEY-----';
16+
17+
$start = memory_get_usage(true);
18+
for ($i = 0; $i < 100000; $i++) {
19+
$a = openssl_get_publickey($b);
20+
openssl_free_key($a);
21+
}
22+
$end = memory_get_usage(true);
23+
var_dump($end <= 1.1 * $start);
24+
?>
25+
--EXPECT--
26+
bool(true)

0 commit comments

Comments
 (0)