summaryrefslogtreecommitdiff
path: root/ext/standard/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/file.c')
-rw-r--r--ext/standard/file.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 31121cf2b4..f1d283f106 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -1052,7 +1052,7 @@ exit_failed:
PHPAPI PHP_FUNCTION(fgetc)
{
zval **arg1;
- char *buf;
+ char buf[2];
int result;
php_stream *stream;
@@ -1062,18 +1062,15 @@ PHPAPI PHP_FUNCTION(fgetc)
PHP_STREAM_TO_ZVAL(stream, arg1);
- buf = safe_emalloc(2, sizeof(char), 0);
-
result = php_stream_getc(stream);
if (result == EOF) {
- efree(buf);
RETVAL_FALSE;
} else {
buf[0] = result;
buf[1] = '\0';
- RETURN_STRINGL(buf, 1, 0);
+ RETURN_STRINGL(buf, 1, 1);
}
}
/* }}} */