Skip to content

Commit 6249172

Browse files
committed
Optimize openssl memory leak test
Just do one call and check whether memory usage changes. Looping this 100000 times is extremely slow with debug builds of openssl.
1 parent c2b017a commit 6249172

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

ext/openssl/tests/bug79145.phpt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
Bug #79145 (openssl memory leak)
33
--EXTENSIONS--
44
openssl
5-
--SKIPIF--
6-
<?php
7-
if (getenv('SKIP_SLOW_TESTS')) die('skip slow test');
8-
?>
95
--FILE--
106
<?php
117
$b = '-----BEGIN PUBLIC KEY-----
@@ -15,13 +11,14 @@ j85Q5OliVxOdB1LoTOsOmfFf/fdvpU3DsOWsDKlVrL41MHxXorwrwOiys/r/gv2d
1511
C9C4JmhTOjBVAK8SewIDAQAC
1612
-----END PUBLIC KEY-----';
1713

14+
$a = openssl_get_publickey($b);
15+
@openssl_free_key($a);
16+
1817
$start = memory_get_usage(true);
19-
for ($i = 0; $i < 100000; $i++) {
20-
$a = openssl_get_publickey($b);
21-
@openssl_free_key($a);
22-
}
18+
$a = openssl_get_publickey($b);
19+
@openssl_free_key($a);
2320
$end = memory_get_usage(true);
24-
var_dump($end <= 1.1 * $start);
21+
var_dump($end == $start);
2522
?>
2623
--EXPECT--
2724
bool(true)

0 commit comments

Comments
 (0)