xref: /php-src/ext/standard/tests/serialize/002.phpt (revision a555cc0b)
1--TEST--
2Bug #25378 (unserialize() crashes with invalid data)
3--FILE--
4<?php
5var_dump(unserialize('b:0;'));
6var_dump(unserialize('b:1;'));
7var_dump(unserialize('i:823;'));
8var_dump(unserialize('s:0:"";'));
9var_dump(unserialize('s:3:"foo";'));
10var_dump(unserialize('a:1:{i:0;s:2:"12";}'));
11var_dump(unserialize('a:2:{i:0;a:0:{}i:1;a:0:{}}'));
12var_dump(unserialize('a:3:{i:0;s:3:"foo";i:1;s:3:"bar";i:2;s:3:"baz";}'));
13var_dump(unserialize('O:8:"stdClass":0:{}'));
14?>
15--EXPECTF--
16bool(false)
17bool(true)
18int(823)
19string(0) ""
20string(3) "foo"
21array(1) {
22  [0]=>
23  string(2) "12"
24}
25array(2) {
26  [0]=>
27  array(0) {
28  }
29  [1]=>
30  array(0) {
31  }
32}
33array(3) {
34  [0]=>
35  string(3) "foo"
36  [1]=>
37  string(3) "bar"
38  [2]=>
39  string(3) "baz"
40}
41object(stdClass)#%d (0) {
42}
43