1--TEST--
2Bug#54946 stream_get_contents infinite loop
3--FILE--
4<?php
5$filename = tempnam(__DIR__, "phpbug");
6$stream = fopen($filename, "w"); // w or a
7$retval = stream_get_contents($stream, 1, 1);
8fclose($stream);
9var_dump($retval);
10unlink($filename);
11
12
13
14$filename = tempnam(__DIR__, "phpbug2");
15
16$stream = fopen($filename, "a");
17$retval = stream_get_contents($stream, 1, 1);
18var_dump($retval);
19fclose($stream);
20unlink($filename);
21
22
23
24$filename = tempnam(__DIR__, "phpbug3");
25
26$stream = fopen($filename, "a");
27fseek($stream, 1);
28$retval = stream_get_contents($stream, 1);
29var_dump($retval);
30fclose($stream);
31unlink($filename);
32?>
33===DONE===
34--EXPECTF--
35Notice: stream_get_contents(): read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
36string(0) ""
37
38Notice: stream_get_contents(): read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
39string(0) ""
40
41Notice: stream_get_contents(): read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
42string(0) ""
43===DONE===
44