xref: /PHP-5.5/ext/wddx/tests/bug48562.phpt (revision a18cede1)
1--TEST--
2Bug #48562 (Reference recursion causes segfault when used in wddx_serialize_vars())
3--SKIPIF--
4<?php
5if (!extension_loaded('wddx')) {
6    die('skip. wddx not available');
7}
8?>
9--FILE--
10<?php
11
12$foo = 'bar';
13
14$a['x'] = 'foo';
15$a['x'] = &$a;
16
17var_dump(wddx_serialize_vars($a));
18
19// replace $a - the recursion detection seems to be causing $a to be not an array here, maybe its internally a pointer
20// replacing $a with a new array() allows this test to still check for 2 things
21//  1. recursion detection in &$a;
22//  2. recursion detection in adding $a to itself and then serializing $a
23// the one thing the test won't check is using $a as an array after doing &$a; which isn't really a wddx problem.
24$a = array();
25$a['x'] = 'foo';
26$a['x'] = $a;
27
28var_dump(wddx_serialize_vars($a));
29
30?>
31--EXPECTF--
32Warning: wddx_serialize_vars(): recursion detected in %s on line %d
33string(78) "<wddxPacket version='1.0'><header/><data><struct></struct></data></wddxPacket>"
34string(120) "<wddxPacket version='1.0'><header/><data><struct><var name='foo'><string>bar</string></var></struct></data></wddxPacket>"
35