From 6d57337cda427bb8f9e4fa28f53351ae54da08a2 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 5 Nov 2002 16:19:19 +0000 Subject: [PATCH] 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. --- ext/standard/array.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); } -- 2.50.1