summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/openssl.c2
-rw-r--r--ext/openssl/tests/bug79145.phpt26
2 files changed, 26 insertions, 2 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index e0e10973be..bb3880f518 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -4445,7 +4445,6 @@ PHP_FUNCTION(openssl_pkey_get_public)
RETURN_FALSE;
}
ZVAL_RES(return_value, res);
- Z_ADDREF_P(return_value);
}
/* }}} */
@@ -4487,7 +4486,6 @@ PHP_FUNCTION(openssl_pkey_get_private)
RETURN_FALSE;
}
ZVAL_RES(return_value, res);
- Z_ADDREF_P(return_value);
}
/* }}} */
diff --git a/ext/openssl/tests/bug79145.phpt b/ext/openssl/tests/bug79145.phpt
new file mode 100644
index 0000000000..348831189b
--- /dev/null
+++ b/ext/openssl/tests/bug79145.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #79145 (openssl memory leak)
+--SKIPIF--
+<?php
+if (!extension_loaded('openssl')) die('skip openssl extension not available');
+if (getenv('SKIP_SLOW_TESTS')) die('skip slow test');
+?>
+--FILE--
+<?php
+$b = '-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDaFhc31WeskqxwI+Si5R/fZrLK
+pJOlABiI3RZfKCHJVrXl3IvcHDFM/BHKUJoSi/ee8GS9iw0G4Z1eCzJdthXxHARh
+j85Q5OliVxOdB1LoTOsOmfFf/fdvpU3DsOWsDKlVrL41MHxXorwrwOiys/r/gv2d
+C9C4JmhTOjBVAK8SewIDAQAC
+-----END PUBLIC KEY-----';
+
+$start = memory_get_usage(true);
+for ($i = 0; $i < 100000; $i++) {
+ $a = openssl_get_publickey($b);
+ openssl_free_key($a);
+}
+$end = memory_get_usage(true);
+var_dump($end <= 1.1 * $start);
+?>
+--EXPECT--
+bool(true)