From a4363b1f7f49f65f93edeec757ddce6d4c5225c7 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 9 Feb 2008 19:46:49 +0000 Subject: [PATCH] Fixed bugs: - #42036 fgetc() sets end of the file flag when reading on write only file - #42037 fgetc() retuns one char when fails to read on php6 --- ext/standard/file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/standard/file.c b/ext/standard/file.c index 33aa913f38..8a922b6b1a 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1181,14 +1181,16 @@ PHPAPI PHP_FUNCTION(fgetc) int buflen = 1; UChar *buf = php_stream_read_unicode_chars(stream, &buflen); - if (!buf) { + if (!buf || !buflen) { RETURN_FALSE; } RETURN_UNICODEL(buf, buflen, 0); } else { /* IS_STRING */ char buf[2]; - buf[0] = php_stream_getc(stream); + if ((buf[0] = php_stream_getc(stream)) == EOF) { + RETURN_FALSE; + } buf[1] = 0; RETURN_STRINGL(buf, 1, 1); } -- 2.50.1