com php-src: Fixed array_push(): ext/standard/array .c

From: Date: Fri, 28 Feb 2014 11:48:39 +0000
Subject: com php-src: Fixed array_push(): ext/standard/array .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77772@lists.php.net to get a copy of this message
Commit: 2bf30181691ccd6e4d64d3d9d7d0dd8587f8485d Author: Dmitry Stogov <dmitry@zend.com> Fri, 28 Feb 2014 15:48:39 +0400 Parents: feeca5aba6405c531420f11888109036e95431ae Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2bf30181691ccd6e4d64d3d9d7d0dd8587f8485d Log: Fixed array_push() Changed paths: M ext/standard/array.c Diff: diff --git a/ext/standard/array.c b/ext/standard/array.c index 69f2fe5..659ab25 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1888,9 +1888,9 @@ PHPAPI HashTable* php_splice(HashTable *in_hash, int offset, int length, zval *l Pushes elements onto the end of the array */ PHP_FUNCTION(array_push) { - zval ***args, /* Function arguments array */ + zval *args, /* Function arguments array */ *stack, /* Input array */ - *new_var; /* Variable to be pushed */ + new_var; /* Variable to be pushed */ int i, /* Loop counter */ argc; /* Number of function arguments */ @@ -1901,11 +1901,10 @@ PHP_FUNCTION(array_push) /* For each subsequent argument, make it a reference, increase refcount, and add it to the end of the array */ for (i = 0; i < argc; i++) { - new_var = *args[i]; - Z_ADDREF_P(new_var); + ZVAL_COPY(&new_var, &args[i]); - if (zend_hash_next_index_insert(Z_ARRVAL_P(stack), new_var) == NULL) { - Z_DELREF_P(new_var); + if (zend_hash_next_index_insert(Z_ARRVAL_P(stack), &new_var) == NULL) { + if (Z_REFCOUNTED(new_var)) Z_DELREF(new_var); 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;

« previous php.cvs (#77772) next »