Index: ext/spl/spl_array.c =================================================================== RCS file: /repository/php-src/ext/spl/spl_array.c,v retrieving revision 1.71.2.17.2.17 diff -u -p -r1.71.2.17.2.17 spl_array.c --- ext/spl/spl_array.c 5 Oct 2008 14:49:25 -0000 1.71.2.17.2.17 +++ ext/spl/spl_array.c 6 Oct 2008 13:42:56 -0000 @@ -1197,6 +1197,7 @@ static void spl_array_method(INTERNAL_FU 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; INIT_PZVAL(&tmp); Z_TYPE(tmp) = IS_ARRAY; @@ -1207,9 +1208,12 @@ static void spl_array_method(INTERNAL_FU zend_throw_exception(spl_ce_BadMethodCallException, "Function expects exactly one argument", 0 TSRMLS_CC); return; } - 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 { - 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); + } + if (retval_ptr) { + COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr); } } Index: ext/spl/tests/bug46115.phpt =================================================================== RCS file: ext/spl/tests/bug46115.phpt diff -N ext/spl/tests/bug46115.phpt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ext/spl/tests/bug46115.phpt 6 Oct 2008 13:42:56 -0000 @@ -0,0 +1,11 @@ +--TEST-- +Bug #46115 (Memory leak when calling a method using Reflection) +--FILE-- +invoke($h); +?> +DONE +--EXPECT-- +DONE