File: igbinary_059.phpt

package info (click to toggle)
php-igbinary 3.2.16-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,024 kB
  • sloc: ansic: 3,373; xml: 1,106; pascal: 10; makefile: 2; php: 2; sh: 1
file content (56 lines) | stat: -rw-r--r-- 1,269 bytes parent folder | download | duplicates (6)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
--TEST--
igbinary_unserialize should never convert from packed array to hash when references exist (Bug #48)
--SKIPIF--
--FILE--
<?php
function main() {
	$result = array();
	// The default hash size is 16. If we start with 0, and aren't careful, the array would begin as a packed array,
	// and the references would be invalidated when key 50 (>= 16) is added (converted to a hash), causing a segfault.
	foreach (array(0, 50) as $i) {
	    $inner = new stdClass();
	    $inner->a = $i;
	    $result[0][0][$i] = $inner;
	    $result[1][] = $inner;
	}
	$serialized = igbinary_serialize($result);
	printf("%s\n", bin2hex(substr($serialized, 4)));
	flush();
	$unserialized = igbinary_unserialize($serialized);
	var_dump($unserialized);
}
main();
?>
--EXPECTF--
1402060014010600140206001708737464436c6173731401110161060006321a0014010e010632060114020600220306012204
array(2) {
  [0]=>
  array(1) {
    [0]=>
    array(2) {
      [0]=>
      object(stdClass)#%d (1) {
        ["a"]=>
        int(0)
      }
      [50]=>
      object(stdClass)#%d (1) {
        ["a"]=>
        int(50)
      }
    }
  }
  [1]=>
  array(2) {
    [0]=>
    object(stdClass)#%d (1) {
      ["a"]=>
      int(0)
    }
    [1]=>
    object(stdClass)#%d (1) {
      ["a"]=>
      int(50)
    }
  }
}