]> granicus.if.org Git - php/commitdiff
Fixed bug #41685 (array_push() fails to warn when next index is already
authorIlia Alshanetsky <iliaa@php.net>
Sun, 24 Jun 2007 17:37:01 +0000 (17:37 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 24 Jun 2007 17:37:01 +0000 (17:37 +0000)
occupied).

NEWS
ext/standard/array.c

diff --git a/NEWS b/NEWS
index d5f65faaf85e658ab0109e9c3951f8fb16922a23..477e7c7f618d96ca2c830bff59dae41f22076e6e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,8 @@ PHP                                                                        NEWS
 - Fixed bug #41717 (imagepolygon does not respect thickness). (Pierre)
 - Fixed bug #41686 (Omitting length param in array_slice not possible).
   (Ilia)
+- Fixed bug #41685 (array_push() fails to warn when next index is already
+  occupied). (Ilia)
 - Fixed bug #41655 (open_basedir bypass via glob()). (Ilia)
 - Fixed bug #41640 (get_class_vars produces error on class constants).
   (Johannes)
index b698ead1ee638a4e5a2c5be198628907a4736827..3ac7a2ae75799ea2bbc91818d07e35c78f90b90a 100644 (file)
@@ -1957,7 +1957,11 @@ PHP_FUNCTION(array_push)
                new_var = *args[i];
                new_var->refcount++;
        
-               zend_hash_next_index_insert(Z_ARRVAL_P(stack), &new_var, sizeof(zval *), NULL);
+               if (zend_hash_next_index_insert(Z_ARRVAL_P(stack), &new_var, sizeof(zval *), NULL) == FAILURE) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element to the array as the next element is already occupied");
+                       efree(args);
+                       RETURN_FALSE;
+               }
        }
        
        /* Clean up and return the number of values in the stack */