From: Dmitry Stogov Date: Thu, 14 Feb 2008 08:46:08 +0000 (+0000) Subject: Fixed memory leak X-Git-Tag: php-5.2.6RC1~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84485910968c5f28728369291467a243d8e97d90;p=php Fixed memory leak --- diff --git a/ext/standard/array.c b/ext/standard/array.c index f809c91ff3..f4431ed9eb 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1975,6 +1975,7 @@ PHP_FUNCTION(array_push) new_var->refcount++; if (zend_hash_next_index_insert(Z_ARRVAL_P(stack), &new_var, sizeof(zval *), NULL) == FAILURE) { + new_var->refcount--; php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element to the array as the next element is already occupied"); efree(args); RETURN_FALSE; diff --git a/ext/standard/tests/array/array_push_variation4.phpt b/ext/standard/tests/array/array_push_variation4.phpt index 5bb20f32c6..2d02fa93ff 100644 --- a/ext/standard/tests/array/array_push_variation4.phpt +++ b/ext/standard/tests/array/array_push_variation4.phpt @@ -32,6 +32,9 @@ echo "\n-- Pass \$var argument which is a reference to \$stack argument --\n"; var_dump(array_push($array, &$array)); var_dump($array); +/* break cycle */ +$array[9] = null; + echo "Done"; ?> --EXPECTF--