diff options
author | Julien Pauli <jpauli@php.net> | 2014-12-12 16:50:42 +0100 |
---|---|---|
committer | Julien Pauli <jpauli@php.net> | 2014-12-12 16:50:42 +0100 |
commit | a0d848f795b14996d1707f5a5059f8ffe83e3095 (patch) | |
tree | 9c6ec343b4581a42fd6e4600401241060acc0523 /main/streams/memory.c | |
parent | 4cda98264ec4ab80e9ca54c10cf2f332d6e09290 (diff) | |
parent | d43d0663af9d7f11985fa6994f785b2dd5cb0faa (diff) | |
download | php-git-a0d848f795b14996d1707f5a5059f8ffe83e3095.tar.gz |
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
Updated NEWS
Fix bug #68532: convert.base64-encode omits padding bytes
Diffstat (limited to 'main/streams/memory.c')
-rw-r--r-- | main/streams/memory.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/main/streams/memory.c b/main/streams/memory.c index 09421ea49d..81275f7797 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -87,15 +87,19 @@ static size_t php_stream_memory_read(php_stream *stream, char *buf, size_t count php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract; assert(ms != NULL); - if (ms->fpos + count >= ms->fsize) { - count = ms->fsize - ms->fpos; + if (ms->fpos == ms->fsize) { stream->eof = 1; - } - if (count) { - assert(ms->data!= NULL); - assert(buf!= NULL); - memcpy(buf, ms->data+ms->fpos, count); - ms->fpos += count; + count = 0; + } else { + if (ms->fpos + count >= ms->fsize) { + count = ms->fsize - ms->fpos; + } + if (count) { + assert(ms->data!= NULL); + assert(buf!= NULL); + memcpy(buf, ms->data+ms->fpos, count); + ms->fpos += count; + } } return count; } |