com php-src: Fix bug #46103: NEWS ext/reflection/php_reflecti on.c ext/reflection/tests/bug46103.phpt
| From: | Nikita Popov | Date: | Sun, 18 Dec 2016 16:10:19 +0000 |
| Subject: | com php-src: Fix bug #46103: NEWS ext/reflection/php_reflecti on.c ext/reflection/tests/bug46103.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96368@lists.php.net to get a copy of this message | ||
Commit: c1af9f282f62eaf8a5973068ce373a800e0f752c
Author: Nikita Popov <nikic@php.net> Sun, 18 Dec 2016 17:10:19 +0100
Parents: eb636fcb56911e5b79de83fa8886b12f702d9920
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c1af9f282f62eaf8a5973068ce373a800e0f752c
Log:
Fix bug #46103
Bugs:
https://bugs.php.net/46103
Changed paths:
M NEWS
M ext/reflection/php_reflection.c
A ext/reflection/tests/bug46103.phpt
Diff:
diff --git a/NEWS b/NEWS
index 2285d5d..60995ad 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,10 @@ PHP NEWS
(Bob)
. Fixed issue getting executable lines from custom wrappers. (Bob)
+- Reflection:
+ . Fixed bug #46103 (ReflectionObject memory leak). (Nikita)
+
+
08 Dec 2016 PHP 7.0.14
- Core:
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index b24f9c6..1c13aa5 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -344,6 +344,15 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */
}
/* }}} */
+static HashTable *reflection_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */
+{
+ reflection_object *intern = Z_REFLECTION_P(obj);
+ *gc_data = &intern->obj;
+ *gc_data_count = 1;
+ return zend_std_get_properties(obj);
+}
+/* }}} */
+
static zend_object *reflection_objects_new(zend_class_entry *class_type) /* {{{ */
{
reflection_object *intern;
@@ -6524,6 +6533,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
reflection_object_handlers.free_obj = reflection_free_objects_storage;
reflection_object_handlers.clone_obj = NULL;
reflection_object_handlers.write_property = _reflection_write_property;
+ reflection_object_handlers.get_gc = reflection_get_gc;
INIT_CLASS_ENTRY(_reflection_entry, "ReflectionException",
reflection_exception_functions);
reflection_exception_ptr = zend_register_internal_class_ex(&_reflection_entry,
zend_ce_exception);
diff --git a/ext/reflection/tests/bug46103.phpt b/ext/reflection/tests/bug46103.phpt
new file mode 100644
index 0000000..978a9c2
--- /dev/null
+++ b/ext/reflection/tests/bug46103..phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #46103: ReflectionObject memory leak
+--FILE--
+<?php
+
+$obj = new stdClass;
+$obj->r = new ReflectionObject($obj);
+var_dump($obj);
+
+?>
+--EXPECT--
+object(stdClass)#1 (1) {
+ ["r"]=>
+ object(ReflectionObject)#2 (1) {
+ ["name"]=>
+ string(8) "stdClass"
+ }
+}