bjori Sun Nov 12 01:14:39 2006 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/standard/tests/array bug36975.phpt
Modified files:
/php-src/ext/standard array.c
/php-src NEWS
Log:
MFH: Fixed bug#36975 (natcasesort() causes array_pop() to misbehave)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.14&r2=1.308.2.21.2.15&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.14
php-src/ext/standard/array.c:1.308.2.21.2.15
--- php-src/ext/standard/array.c:1.308.2.21.2.14 Tue Oct 3 17:41:47 2006
+++ php-src/ext/standard/array.c Sun Nov 12 01:14:39 2006
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.308.2.21.2.14 2006/10/03 17:41:47 iliaa Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.15 2006/11/12 01:14:39 bjori Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -2033,7 +2033,7 @@
if (should_rehash) {
zend_hash_rehash(Z_ARRVAL_PP(stack));
}
- } else if (!key_len) {
+ } else if (!key_len && index >= Z_ARRVAL_PP(stack)->nNextFreeElement-1)
{
Z_ARRVAL_PP(stack)->nNextFreeElement =
Z_ARRVAL_PP(stack)->nNextFreeElement - 1;
}
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.356&r2=1.2027.2.547.2.357&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.356 php-src/NEWS:1.2027.2.547.2.357
--- php-src/NEWS:1.2027.2.547.2.356 Fri Nov 10 18:51:05 2006
+++ php-src/NEWS Sun Nov 12 01:14:39 2006
@@ -73,6 +73,7 @@
(Dmitry)
- Fixed bug #38456 (Apache2 segfaults when virtual() is called in .php
ErrorDocument). (Ilia)
+- Fixed bug #36975 (natcasesort() causes array_pop() to misbehave). (Hannes)
- Fixed bug #33282 (Re-assignment by reference does not clear the is_ref flag)
(Ilia,Dmitry, Matt Wilmas)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug36975.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/bug36975.phpt
+++ php-src/ext/standard/tests/array/bug36975.phpt
--TEST--
Bug#36975 (natcasesort() causes array_pop() to misbehave)
--FILE--
<?php
$a = array('aa', 'aa', 'bb', 'bb', 'cc', 'cc');
$test = natcasesort($a);
if ($test) {
echo "natcasesort success!\n";
}
$val = array_pop($a);
$a[] = $val;
var_dump($a);
$b = array(1 => 'foo', 0 => 'baz');
array_pop($b);
$b[] = 'bar';
array_push($b, 'bar');
print_r($b);
$c = array(0, 0, 0, 0, 0);
asort($c);
array_pop($c);
$c[] = 'foo';
$c[] = 'bar';
var_dump($c);
?>
--EXPECT--
natcasesort success!
array(6) {
[0]=>
string(2) "aa"
[1]=>
string(2) "aa"
[3]=>
string(2) "bb"
[2]=>
string(2) "bb"
[5]=>
string(2) "cc"
[6]=>
string(2) "cc"
}
Array
(
[1] => foo
[2] => bar
[3] => bar
)
array(6) {
[4]=>
int(0)
[3]=>
int(0)
[2]=>
int(0)
[1]=>
int(0)
[5]=>
string(3) "foo"
[6]=>
string(3) "bar"
}
--UEXPECT--
natcasesort success!
array(6) {
[0]=>
unicode(2) "aa"
[1]=>
unicode(2) "aa"
[3]=>
unicode(2) "bb"
[2]=>
unicode(2) "bb"
[5]=>
unicode(2) "cc"
[6]=>
unicode(2) "cc"
}
Array
(
[1] => foo
[2] => bar
[3] => bar
)
array(6) {
[4]=>
int(0)
[3]=>
int(0)
[2]=>
int(0)
[1]=>
int(0)
[5]=>
unicode(3) "foo"
[6]=>
unicode(3) "bar"
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php