com php-src: Fixed #71837 (Wrong arrays behaviour): NEWS ext/standard/array.c ext/standard/tests/array/bug71837.phpt

From: Date: Thu, 17 Mar 2016 14:41:41 +0000
Subject: com php-src: Fixed #71837 (Wrong arrays behaviour): NEWS ext/standard/array.c ext/standard/tests/array/bug71837.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-91400@lists.php.net to get a copy of this message
Commit: 345ecd9822820a54134bd53a6e449e1f22612e19 Author: Xinchen Hui <laruence@gmail.com> Thu, 17 Mar 2016 07:41:41 -0700 Parents: 383dde5b15a134ee1bec40dedebe6554d742efd5 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=345ecd9822820a54134bd53a6e449e1f22612e19 Log: Fixed #71837 (Wrong arrays behaviour) Bugs: https://bugs.php.net/71837 Changed paths: M NEWS M ext/standard/array.c A ext/standard/tests/array/bug71837.phpt Diff: diff --git a/NEWS b/NEWS index 419fbc4..5329582 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ PHP NEWS (Laruence) - Standard: + . Fixed bug #71837 (Wrong arrays behaviour). (Laruence) . Fixed bug #71840 (Unserialize accepts wrongly data). (Ryat, Laruence) 31 Mar 2016 PHP 7.0.5 diff --git a/ext/standard/array.c b/ext/standard/array.c index 4d2c45e..4ff373a 100644 --- a/ext/standard/array..c +++ b/ext/standard/array.c @@ -3198,6 +3198,9 @@ static inline void php_array_merge_or_replace_wrapper(INTERNAL_FUNCTION_PARAMETE src = Z_ARRVAL_P(arg); dest = Z_ARRVAL_P(return_value); ZEND_HASH_FOREACH_KEY_VAL(src, idx, string_key, src_entry) { + if (UNEXPECTED(Z_ISREF_P(src_entry) && Z_REFCOUNT_P(src_entry) == 1)) { + src_entry = Z_REFVAL_P(src_entry); + } if (string_key) { if (Z_REFCOUNTED_P(src_entry)) { Z_ADDREF_P(src_entry); @@ -3235,6 +3238,9 @@ static inline void php_array_merge_or_replace_wrapper(INTERNAL_FUNCTION_PARAMETE src = Z_ARRVAL_P(arg); dest = Z_ARRVAL_P(return_value); ZEND_HASH_FOREACH_STR_KEY_VAL(src, string_key, src_entry) { + if (UNEXPECTED(Z_ISREF_P(src_entry) && Z_REFCOUNT_P(src_entry) == 1)) { + src_entry = Z_REFVAL_P(src_entry); + } if (string_key) { if (Z_REFCOUNTED_P(src_entry)) { Z_ADDREF_P(src_entry); diff --git a/ext/standard/tests/array/bug71837.phpt b/ext/standard/tests/array/bug71837.phpt new file mode 100644 index 0000000..686d144 --- /dev/null +++ b/ext/standard/tests/array/bug71837.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #71837 (Wrong arrays behaviour) +--FILE-- +<?php + +$p = array(array()); +array_push($p[0], array(100)); + +$c = array_merge($p, array()); +$c[0][0] = 200; + +print_r($p); + +?> +--EXPECT-- +Array +( + [0] => Array + ( + [0] => Array + ( + [0] => 100 + ) + + ) + +)

« previous php.cvs (#91400) next »