]> granicus.if.org Git - php/commitdiff
Fix fgetc (#6259) and ftell error condition returns
authorStanislav Malyshev <stas@php.net>
Sun, 20 Aug 2000 13:24:14 +0000 (13:24 +0000)
committerStanislav Malyshev <stas@php.net>
Sun, 20 Aug 2000 13:24:14 +0000 (13:24 +0000)
ext/standard/file.c

index d86dd5ac5cc9d0358c261115f23f5c8104c6d75b..82ae4d2f4d7337b57802034c9208111658c59677 100644 (file)
@@ -1019,8 +1019,8 @@ PHP_FUNCTION(fgetc) {
                socketd=*(int*)what;
        }
 
-       buf = emalloc(sizeof(char) * 2);
-       if (!(*buf = FP_FGETC(socketd, (FILE*)what, issock))) {
+       buf = emalloc(sizeof(int));
+       if ((*buf = FP_FGETC(socketd, (FILE*)what, issock)) == EOF) {
                efree(buf);
                RETVAL_FALSE;
        } else {
@@ -1320,6 +1320,7 @@ PHP_FUNCTION(ftell)
 {
        pval **arg1;
        void *what;
+       long ret;
        
        if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
                WRONG_PARAM_COUNT;
@@ -1327,8 +1328,13 @@ PHP_FUNCTION(ftell)
        
        what = zend_fetch_resource(arg1,-1,"File-Handle",NULL,2,le_fopen,le_popen);
        ZEND_VERIFY_RESOURCE(what);
+
+       ret = ftell((FILE*) what);
+       if(ret == -1) {
+               RETURN_FALSE;
+       } 
        
-       RETURN_LONG(ftell((FILE*) what));
+       RETURN_LONG(ret);
 }
 
 /* }}} */