From 1ac71c4fe94644571aecd92bf9425e61d3cbf8bb Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 4 Mar 2007 17:21:16 +0000 Subject: Fixed bug #40709 (array_reduce() behaves strange with one item stored arrays). --- NEWS | 2 ++ ext/standard/array.c | 4 +--- ext/standard/tests/array/bug40709.phpt | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 ext/standard/tests/array/bug40709.phpt diff --git a/NEWS b/NEWS index 1cbf7898a5..2d81830e77 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ PHP NEWS - Added --ri switch to CLI which allows to check extension information. (Marcus) - Added tidyNode::getParent() method (John, Nuno) - Fixed zend_llist_remove_tail (Michael Wallner, Dmitry) +- Fixed bug #40709 (array_reduce() behaves strange with one item stored arrays). + (Ilia) - Fixed bug #40678 (Cross compilation fails). (Tony) - Fixed bug #40621 (Crash when constructor called inappropriately). (Tony) - Fixed bug #40609 (Segfaults when using more than one SoapVar in a request). diff --git a/ext/standard/array.c b/ext/standard/array.c index be3e73c191..29b9e8dc41 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4077,10 +4077,8 @@ PHP_FUNCTION(array_reduce) while (zend_hash_get_current_data_ex(htbl, (void **)&operand, &pos) == SUCCESS) { if (result) { zend_fcall_info fci; - args[0] = &result; args[1] = operand; - fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = *callback; @@ -4106,7 +4104,7 @@ PHP_FUNCTION(array_reduce) zend_hash_move_forward_ex(htbl, &pos); } - RETVAL_ZVAL(result, 0, 1); + RETVAL_ZVAL(result, 1, 1); } /* }}} */ diff --git a/ext/standard/tests/array/bug40709.phpt b/ext/standard/tests/array/bug40709.phpt new file mode 100644 index 0000000000..6ab6bbd410 --- /dev/null +++ b/ext/standard/tests/array/bug40709.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #40709 (array_reduce() behaves strange with one item stored arrays) +--SKIPIF-- +--FILE-- + +--EXPECT-- +result for arr1: 1,2,3 +result for arr2: 1 +result for arr1: 1,2,3 +result for arr2: 1 +Done -- cgit v1.2.1