diff options
author | Sara Golemon <pollita@php.net> | 2004-09-08 18:42:15 +0000 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2004-09-08 18:42:15 +0000 |
commit | d179ac771c6be8ef64dee154bae55e8a4caedb67 (patch) | |
tree | 99d0dca1b6446bdcc30eee6c018302ec659a959d /main/streams/streams.c | |
parent | da5ff5d9f1ca9ec9bdd16b6a367c6de533b83bf8 (diff) | |
download | php-git-d179ac771c6be8ef64dee154bae55e8a4caedb67.tar.gz |
Handle maxlen when stream can't be mmaped
Diffstat (limited to 'main/streams/streams.c')
-rwxr-xr-x | main/streams/streams.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c index a7c65dde57..fc5a0b82ee 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1211,6 +1211,17 @@ PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen } } + if (maxlen > 0) { + ptr = *buf = pemalloc_rel_orig(maxlen + 1, persistent); + while ((len < maxlen) & !php_stream_eof(src)) { + ret = php_stream_read(src, ptr, maxlen - len); + len += ret; + ptr += ret; + } + *ptr = '\0'; + return len; + } + /* avoid many reallocs by allocating a good sized chunk to begin with, if * we can. Note that the stream may be filtered, in which case the stat * result may be inaccurate, as the filter may inflate or deflate the |