diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2015-10-08 14:59:02 +0300 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2015-10-08 14:59:02 +0300 |
| commit | 3815e9713601a637b30bb99d631fc68df97f9288 (patch) | |
| tree | 49cb738732480aa5062d06f97f931d8c161037ed | |
| parent | 9af07e7119a150acd5911c97da5d91fe9e424570 (diff) | |
| download | php-git-3815e9713601a637b30bb99d631fc68df97f9288.tar.gz | |
Fixed bug #70668 (array_keys() doesn't respect references when $strict is true)
| -rw-r--r-- | NEWS | 3 | ||||
| -rw-r--r-- | ext/standard/array.c | 1 | ||||
| -rw-r--r-- | ext/standard/tests/array/bug70668.phpt | 63 |
3 files changed, 67 insertions, 0 deletions
@@ -18,6 +18,9 @@ PHP NEWS - Standard: . Fixed bug #70667 (strtr() causes invalid writes and a crashes). (Dmitry) + . Fixed bug #70668 (array_keys() doesn't respect references when $strict is + true). (Bob, Dmitry) + 01 Oct 2015, PHP 7.0.0 RC 4 diff --git a/ext/standard/array.c b/ext/standard/array.c index b9d39ea1a2..4678e14488 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3282,6 +3282,7 @@ PHP_FUNCTION(array_keys) if (strict) { ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(input), num_idx, str_idx, entry) { + ZVAL_DEREF(entry); if (fast_is_identical_function(search_value, entry)) { if (str_idx) { ZVAL_STR_COPY(&new_val, str_idx); diff --git a/ext/standard/tests/array/bug70668.phpt b/ext/standard/tests/array/bug70668.phpt new file mode 100644 index 0000000000..b35107a0a6 --- /dev/null +++ b/ext/standard/tests/array/bug70668.phpt @@ -0,0 +1,63 @@ +--TEST-- +Bug #70668 (array_keys() doesn't respect references when $strict is true) +--FILE-- +<?php +$arr = array(1, "1", "", NULL, 0, false, true, array()); + +$s = &$arr[0]; +var_dump(array_keys($arr, $s, true)); + +$s = &$arr[1]; +var_dump(array_keys($arr, $s, true)); + +$s = &$arr[2]; +var_dump(array_keys($arr, $s, true)); + +$s = &$arr[3]; +var_dump(array_keys($arr, $s, true)); + +$s = &$arr[4]; +var_dump(array_keys($arr, $s, true)); + +$s = &$arr[5]; +var_dump(array_keys($arr, $s, true)); + +$s = &$arr[6]; +var_dump(array_keys($arr, $s, true)); + +$s = &$arr[7]; +var_dump(array_keys($arr, $s, true)); +?> +--EXPECT-- +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(2) +} +array(1) { + [0]=> + int(3) +} +array(1) { + [0]=> + int(4) +} +array(1) { + [0]=> + int(5) +} +array(1) { + [0]=> + int(6) +} +array(1) { + [0]=> + int(7) +} |
