diff options
author | Stanislav Malyshev <stas@php.net> | 2000-06-29 13:34:55 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2000-06-29 13:34:55 +0000 |
commit | e8c219fef20f822a2fe7c80d64e4174961db386d (patch) | |
tree | 69411865429d15cc8da510b21f60298c1b1a4c25 | |
parent | 1f828a6e8820f6f5c6abc9833308aafd488b10fd (diff) | |
download | php-git-e8c219fef20f822a2fe7c80d64e4174961db386d.tar.gz |
Make fgets not use maximal buffer length always, but shrink buffer
if it's too big.
-rw-r--r-- | ext/standard/file.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c index d23a3a7d26..99ae196904 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -990,6 +990,10 @@ PHP_FUNCTION(fgets) } else { return_value->value.str.val = buf; return_value->value.str.len = strlen(return_value->value.str.val); + /* resize buffer if it's much larger than the result */ + if(return_value->value.str.len < len/2) { + return_value->value.str.val = erealloc(buf,return_value->value.str.len); + } } return_value->type = IS_STRING; } |