int buflen = len;
UChar *buf = php_stream_read_unicode_chars(stream, &buflen);
- if (!buf) {
- RETURN_FALSE;
- }
-
RETURN_UNICODEL(buf, buflen, 0);
} else { /* IS_STRING */
char *buf = emalloc(len + 1);
int buflen = php_stream_read(stream, buf, len);
- if (!buflen) {
- efree(buf);
- RETURN_FALSE;
- }
buf[buflen] = 0;
RETURN_STRINGL(buf, buflen, 0);
}
--- /dev/null
+--TEST--
+Bug #45585 (fread() return value for EOF inconsistent between PHP 5 and 6)
+--FILE--
+<?php
+$fd = fopen("php://temp","w+");
+fwrite($fd, b"foo");
+fseek($fd, 0, SEEK_SET);
+var_dump($fd, fread($fd, 3), fread($fd, 3));
+fclose($fd);
+?>
+--EXPECTF--
+resource(%d) of type (stream)
+string(3) "foo"
+string(0) ""