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--EXPECTF--
34Notice: stream_get_contents(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
35string(0) ""
36
37Notice: stream_get_contents(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
38string(0) ""
39
40Notice: stream_get_contents(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
41string(0) ""
42