1--TEST--
2GH-15908 (leak / assertion failure in streams.c)
3--CREDITS--
4YuanchengJiang
5LuMingYinDetect
6--FILE--
7<?php
8class TestStream {
9    public $context;
10    private $s = 0;
11    function stream_open($path, $mode, $options, &$opened_path) {
12        return true;
13    }
14    function stream_read($count) {
15        echo "Read done\n";
16        if ($this->s++ == 0)
17            return "a\nbb\ncc";
18        return "";
19    }
20    function stream_eof() {
21        return $this->s >= 2;
22    }
23}
24touch(__DIR__."/gh15908.tmp");
25stream_wrapper_register("test", "TestStream");
26$f = fopen("test://", "r");
27try {
28    file_put_contents(__DIR__."/gh15908.tmp", $f, FILE_USE_INCLUDE_PATH, $f);
29} catch (Error $e) {
30    echo $e->getMessage(), "\n";
31}
32?>
33--CLEAN--
34<?php
35@unlink(__DIR__."/gh15908.tmp");
36?>
37--EXPECT--
38file_put_contents(): supplied resource is not a valid Stream-Context resource
39