]> granicus.if.org Git - php/commitdiff
Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX)
authorXinchen Hui <laruence@php.net>
Sun, 12 Feb 2012 04:59:08 +0000 (04:59 +0000)
committerXinchen Hui <laruence@php.net>
Sun, 12 Feb 2012 04:59:08 +0000 (04:59 +0000)
NEWS
ext/standard/array.c

diff --git a/NEWS b/NEWS
index 3e269e80840e77c311c889ae238ef1ad429beb6d..e4f484e52d2cdce7bc73e33f93b2b04f6295ee4a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
index 060d665195048fab4e6a33eb56553c46c63e7748..3ca1a69a5e9d41e3bdd7645579bbcee0835ef86f 100644 (file)
@@ -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);
+               }
        }
 }
 /* }}} */