diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2002-11-05 16:19:19 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2002-11-05 16:19:19 +0000 |
| commit | 6d57337cda427bb8f9e4fa28f53351ae54da08a2 (patch) | |
| tree | c0e49ffc00f23ff14c4707a2ac7e68ba607e7f4c /ext/standard/array.c | |
| parent | 64d3e88266ebd0d9218976c6b30b345060b8935e (diff) | |
| download | php-git-6d57337cda427bb8f9e4fa28f53351ae54da08a2.tar.gz | |
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.
Diffstat (limited to 'ext/standard/array.c')
| -rw-r--r-- | ext/standard/array.c | 5 |
1 files changed, 4 insertions, 1 deletions
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); } |
