dmitry Fri Sep 19 12:48:45 2008 UTC
Modified files:
/php-src/ext/spl spl_array.c
/php-src/ext/spl/tests bug46115.phpt
Log:
Fixed bug #46115 (Memory leak when calling a method using Reflection)
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_array.c?r1=1.148&r2=1.149&diff_format=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.148 php-src/ext/spl/spl_array.c:1.149
--- php-src/ext/spl/spl_array.c:1.148 Mon Aug 25 19:07:12 2008
+++ php-src/ext/spl/spl_array.c Fri Sep 19 12:48:45 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.148 2008/08/25 19:07:12 jani Exp $ */
+/* $Id: spl_array.c,v 1.149 2008/09/19 12:48:45 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -1230,6 +1230,7 @@
spl_array_object *intern =
(spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
zval *tmp, *arg;
+ zval *retval_ptr = NULL;
MAKE_STD_ZVAL(tmp);
Z_TYPE_P(tmp) = IS_ARRAY;
@@ -1240,14 +1241,15 @@
zend_throw_exception(spl_ce_BadMethodCallException,
"Function expects exactly one argument", 0 TSRMLS_CC);
return;
}
- zval_ptr_dtor(return_value_ptr);
- zend_call_method(NULL, NULL, NULL, fname, fname_len,
return_value_ptr, 2, tmp, arg TSRMLS_CC);
+ zend_call_method(NULL, NULL, NULL, fname, fname_len,
&retval_ptr, 2, tmp, arg TSRMLS_CC);
} else {
- zval_ptr_dtor(return_value_ptr);
- zend_call_method(NULL, NULL, NULL, fname, fname_len,
return_value_ptr, 1, tmp, NULL TSRMLS_CC);
+ zend_call_method(NULL, NULL, NULL, fname, fname_len,
&retval_ptr, 1, tmp, NULL TSRMLS_CC);
}
Z_TYPE_P(tmp) = IS_NULL; /* we want to destroy the zval, not the
hashtable */
zval_ptr_dtor(&tmp);
+ if (retval_ptr) {
+ COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+ }
} /* }}} */
/* {{{ SPL_ARRAY_METHOD */
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug46115.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/spl/tests/bug46115.phpt
diff -u /dev/null php-src/ext/spl/tests/bug46115.phpt:1.2
--- /dev/null Fri Sep 19 12:48:45 2008
+++ php-src/ext/spl/tests/bug46115.phpt Fri Sep 19 12:48:45 2008
@@ -0,0 +1,11 @@
+--TEST--
+Bug #46115 (Memory leak when calling a method using Reflection)
+--FILE--
+<?php
+$h = new RecursiveArrayIterator(array());
+$x = new reflectionmethod('RecursiveArrayIterator', 'asort');
+$z = $x->invoke($h);
+?>
+DONE
+--EXPECT--
+DONE
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php