From 3d898cfa3f7d801a47dc18fe665081ed738b70da Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sun, 12 Feb 2012 04:59:08 +0000 Subject: [PATCH] Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX) --- NEWS | 4 ++++ ext/standard/array.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index bb9183f3a2..a444fcf0e6 100644 --- a/NEWS +++ b/NEWS @@ -42,4 +42,8 @@ PHP NEWS . Fixed bug #60968 (Late static binding doesn't work with ReflectionMethod::invokeArgs()). (Laruence) +- Array: + . Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX). + (Laruence) + <<< NOTE: Insert NEWS from last stable release here prior to actual release! >>> diff --git a/ext/standard/array.c b/ext/standard/array.c index 764697c8b7..bd7d125eba 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1564,11 +1564,15 @@ PHP_FUNCTION(array_fill) num--; zval_add_ref(&val); - zend_hash_index_update(Z_ARRVAL_P(return_value), start_key, &val, sizeof(zval *), NULL); + if (zend_hash_index_update(Z_ARRVAL_P(return_value), start_key, &val, sizeof(zval *), NULL) == FAILURE) { + zval_ptr_dtor(&val); + } while (num--) { zval_add_ref(&val); - zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &val, sizeof(zval *), NULL); + if (zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &val, sizeof(zval *), NULL) == FAILURE) { + zval_ptr_dtor(&val); + } } } /* }}} */ -- 2.40.0