From: Ilia Alshanetsky Date: Tue, 5 Nov 2002 16:19:19 +0000 (+0000) Subject: Fixed a memory leak in array_fill(). X-Git-Tag: php-4.3.0RC1~260 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d57337cda427bb8f9e4fa28f53351ae54da08a2;p=php Fixed a memory leak in array_fill(). The refcount hack is now done for ZE1 only and is slightly faster then the original. After this patch array_fill() can consistently create arrays with >65k elements. --- diff --git a/ext/standard/array.c b/ext/standard/array.c index a1637072dd..4db2871f79 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1397,11 +1397,14 @@ PHP_FUNCTION(array_fill) } newval = *val; while (i--) { - if (!(i%62000)) { +#ifndef ZEND_ENGINE_2 + if (newval->refcount >= 62000) { MAKE_STD_ZVAL(newval); *newval = **val; zval_copy_ctor(newval); + newval->refcount = 0; } +#endif zval_add_ref(&newval); zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &newval, sizeof(zval *), NULL); }