xref: /PHP-8.4/ext/spl/tests/bug73029.phpt (revision 7936c808)
1--TEST--
2Bug #73029: Missing type check when unserializing SplArray
3--FILE--
4<?php
5try {
6$a = 'C:11:"ArrayObject":19:{x:i:0;r:2;;m:a:0:{}}';
7$m = unserialize($a);
8$x = $m[2];
9} catch(UnexpectedValueException $e) {
10    print $e->getMessage() . "\n";
11}
12try {
13$a = 'C:11:"ArrayObject":19:0x:i:0;r:2;;m:a:0:{}}';
14$m = unserialize($a);
15$x = $m[2];
16} catch(UnexpectedValueException $e) {
17    print $e->getMessage() . "\n";
18}
19?>
20DONE
21--EXPECTF--
22Error at offset 10 of 19 bytes
23
24Warning: unserialize(): Error at offset 22 of 43 bytes in %s on line %d
25
26Warning: Trying to access array offset on false in %s on line %d
27DONE
28