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