]> granicus.if.org Git - php/commitdiff
Automatic conversion might cause interpretation of 0xff as EOF, so we store
authorSascha Schumann <sas@php.net>
Wed, 27 Sep 2000 16:08:26 +0000 (16:08 +0000)
committerSascha Schumann <sas@php.net>
Wed, 27 Sep 2000 16:08:26 +0000 (16:08 +0000)
the result in an object of type int first.

Submitted by: melchers@cis.fu-berlin.de

ext/standard/file.c

index cd6a4ef6389f6b6ae7e0b508f3b5e79cee2346de..9d810ca4dc91589a2f3dd77a3bdf1c534443a80d 100644 (file)
@@ -908,6 +908,7 @@ PHP_FUNCTION(fgetc) {
        int issock=0;
        int socketd=0;
        void *what;
+       int result;
        
        if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
                WRONG_PARAM_COUNT;
@@ -922,10 +923,11 @@ PHP_FUNCTION(fgetc) {
        }
 
        buf = emalloc(sizeof(int));
-       if ((*buf = FP_FGETC(socketd, (FILE*)what, issock)) == EOF) {
+       if ((result = FP_FGETC(socketd, (FILE*)what, issock)) == EOF) {
                efree(buf);
                RETVAL_FALSE;
        } else {
+               buf[0]=result;
                buf[1]='\0';
                return_value->value.str.val = buf; 
                return_value->value.str.len = 1;