summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/bug50006.phpt
blob: 948866361a0c4fb9a9976a0c598c9793577b5ed8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
--TEST--
Bug #50006 (Segfault caused by uksort())
--FILE--
<?php

$data = array(
    'bar-bazbazbaz.' => 0,
    'bar-bazbazbaz-' => 0,
    'foo' => 0,
);
uksort($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
(
    [foo] => 0
    [bar-bazbazbaz.] => 0
    [bar-bazbazbaz-] => 0
)