mirror of
https://github.com/php/php-src.git
synced 2025-01-08 20:17:28 +08:00
8b64f74baa
add modify protection to all user array sorts
30 lines
464 B
PHP
30 lines
464 B
PHP
--TEST--
|
|
Bug #50006 (Segfault caused by uksort()) - uasort variant
|
|
--FILE--
|
|
<?php
|
|
|
|
$data = array(
|
|
'bar-bazbazbaz.',
|
|
'bar-bazbazbaz-',
|
|
'foo'
|
|
);
|
|
uasort($data, 'magic_sort_cmp');
|
|
print_r($data);
|
|
|
|
function magic_sort_cmp($a, $b) {
|
|
$a = substr($a, 1);
|
|
$b = substr($b, 1);
|
|
if (!$a) return $b ? -1 : 0;
|
|
if (!$b) return 1;
|
|
return magic_sort_cmp($a, $b);
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Array
|
|
(
|
|
[2] => foo
|
|
[1] => bar-bazbazbaz-
|
|
[0] => bar-bazbazbaz.
|
|
)
|