Skip to content

Commit

Permalink
Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX)
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Feb 12, 2012
1 parent 2e61d04 commit c578917
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -45,6 +45,10 @@ 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)

?? ??? 2012, PHP 5.3.10

(to be added)
Expand Down
8 changes: 6 additions & 2 deletions ext/standard/array.c
Expand Up @@ -1558,11 +1558,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);
}
}
}
/* }}} */
Expand Down

0 comments on commit c578917

Please sign in to comment.