com php-src: Fixed bug #75653: NEWS ext/standard/array.c ext/standard/tests/array/bug75653.phpt

From: Date: Fri, 12 Jan 2018 17:30:22 +0000
Subject: com php-src: Fixed bug #75653: NEWS ext/standard/array.c ext/standard/tests/array/bug75653.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100857@lists.php.net to get a copy of this message
Commit: 8c73fc8027a7293e81c0b2e8dc2674fe34f1eb59 Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 12 Jan 2018 18:30:22 +0100 Parents: f8c889760cbbe1fa30159b571ab85cf726ba81c5 Branches: PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8c73fc8027a7293e81c0b2e8dc2674fe34f1eb59 Log: Fixed bug #75653 Bugs: https://bugs.php.net/75653 Changed paths: M NEWS M ext/standard/array.c A ext/standard/tests/array/bug75653.phpt Diff: diff --git a/NEWS b/NEWS index 21037c1..b3095be 100644 --- a/NEWS +++ b/NEWS @@ -51,6 +51,7 @@ PHP NEWS - Standard: . Fixed bug #75781 (substr_count incorrect result). (Laruence) + . Fixed bug #75653 (array_values don't work on empty array). (Nikita) - Zip: . Display headers (buildtime) and library (runtime) versions in phpinfo diff --git a/ext/standard/array.c b/ext/standard/array.c index 3a55333..91ffe08 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4028,7 +4028,7 @@ PHP_FUNCTION(array_values) /* Return empty input as is */ arrlen = zend_hash_num_elements(arrval); - if (!arrlen) { + if (!arrlen && arrval->nNextFreeElement == arrlen) { RETURN_ZVAL(input, 1, 0); } diff --git a/ext/standard/tests/array/bug75653.phpt b/ext/standard/tests/array/bug75653.phpt new file mode 100644 index 0000000..d11c1e0 --- /dev/null +++ b/ext/standard/tests/array/bug75653.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #75653: array_values don't work on empty array +--FILE-- +<?php + +$array[] = 'data1'; +unset($array[0]); +$array = array_values($array); +$array[] = 'data2'; +$array[] = 'data3'; +var_dump($array); + +?> +--EXPECT-- +array(2) { + [0]=> + string(5) "data2" + [1]=> + string(5) "data3" +}

« previous php.cvs (#100857) next »