]> granicus.if.org Git - php/commitdiff
Fixed bugs:
authorFelipe Pena <felipe@php.net>
Sat, 9 Feb 2008 19:46:49 +0000 (19:46 +0000)
committerFelipe Pena <felipe@php.net>
Sat, 9 Feb 2008 19:46:49 +0000 (19:46 +0000)
- #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

index 33aa913f385fcca5a00a4a809ec0047b49389874..8a922b6b1a43d34753d18f2d70455d44afab87a5 100644 (file)
@@ -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);
        }