]> granicus.if.org Git - php/commitdiff
MFH: bug #46115 (Fixes nothing in 5.2, but sync code)
authorEtienne Kneuss <colder@php.net>
Mon, 6 Oct 2008 13:45:42 +0000 (13:45 +0000)
committerEtienne Kneuss <colder@php.net>
Mon, 6 Oct 2008 13:45:42 +0000 (13:45 +0000)
ext/spl/spl_array.c
ext/spl/tests/bug46115.phpt [new file with mode: 0644]

index 257b503dce50dbcc0f341ec7f605917bdb2f70b5..2760ceaaceee3679e90ae9139f1a4b4f88cecd93 100755 (executable)
@@ -1197,6 +1197,7 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam
        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_FUNCTION_PARAMETERS, char *fname, int fnam
                        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);
        }
 }
 
diff --git a/ext/spl/tests/bug46115.phpt b/ext/spl/tests/bug46115.phpt
new file mode 100644 (file)
index 0000000..71207d8
--- /dev/null
@@ -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