diff options
author | Stanislav Malyshev <stas@php.net> | 2000-08-20 13:24:14 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2000-08-20 13:24:14 +0000 |
commit | ce0c4a799106187bcde96079ca5dfd70900b7528 (patch) | |
tree | 9dda3edbef0dff6f068be54a8c2591aed3955d66 /ext/standard | |
parent | d3aeebdd1f4d68088bb866f849387abcf235acaf (diff) | |
download | php-git-ce0c4a799106187bcde96079ca5dfd70900b7528.tar.gz |
Fix fgetc (#6259) and ftell error condition returns
Diffstat (limited to 'ext/standard')
-rw-r--r-- | ext/standard/file.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c index d86dd5ac5c..82ae4d2f4d 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -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); } /* }}} */ |