xref: /PHP-5.5/Zend/tests/bug34045.phpt (revision 610c7fbe)
1--TEST--
2Bug #34045 (Buffer overflow with serialized object)
3--FILE--
4<?php
5class BasicSingleton
6{
7    private static $instance;
8
9    public function __wakeup() {
10        self::$instance = $this;
11    }
12
13    public static function singleton() {
14        if (!(self::$instance instanceof BasicSingleton)) {
15            $c = __CLASS__;
16            self::$instance = new $c;
17        }
18        return self::$instance;
19    }
20}
21
22$db = BasicSingleton::singleton();
23$db_str = serialize($db);
24$db2 = unserialize($db_str);
25echo "ok\n";
26?>
27--EXPECT--
28ok
29