From: Arnaud Le Blanc Date: Tue, 11 Nov 2008 00:40:05 +0000 (+0000) Subject: Fixed bug #45585 (fread() return value for EOF inconsistent X-Git-Tag: BEFORE_HEAD_NS_CHANGE~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2fe765b5f40f1b16848fd6c5a8ce493a08315c59;p=php Fixed bug #45585 (fread() return value for EOF inconsistent between PHP 5 and 6) --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 0d91456fc2..90ad47f32d 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1984,19 +1984,11 @@ PHPAPI PHP_FUNCTION(fread) 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); } diff --git a/ext/standard/tests/file/bug45585.phpt b/ext/standard/tests/file/bug45585.phpt new file mode 100644 index 0000000000..3e7cda1e88 --- /dev/null +++ b/ext/standard/tests/file/bug45585.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #45585 (fread() return value for EOF inconsistent between PHP 5 and 6) +--FILE-- + +--EXPECTF-- +resource(%d) of type (stream) +string(3) "foo" +string(0) ""