diff options
author | mcq8 <php@mcq8.be> | 2014-12-04 17:36:44 +0100 |
---|---|---|
committer | Julien Pauli <jpauli@php.net> | 2014-12-12 16:42:38 +0100 |
commit | 86f18755362b594c519ccde37c3b3f98158b591e (patch) | |
tree | 30781f970fc7f5ca5cf37a5fc7c400da1b30d9b1 /main/streams | |
parent | d6eb3b49c878ce01f1d9d73eebc4d9fec4330573 (diff) | |
download | php-git-86f18755362b594c519ccde37c3b3f98158b591e.tar.gz |
Fix bug #68532: convert.base64-encode omits padding bytes
Diffstat (limited to 'main/streams')
-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 e6d0baaa86..f73c12f7d7 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; } |