summaryrefslogtreecommitdiff
path: root/main/streams
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-06-19 14:04:54 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-06-19 15:09:00 +0200
commitf26e77b05fe14e580e982c75887314b7fae7b777 (patch)
tree57ba63d10b9be65f283b9b869fb3ca692193f712 /main/streams
parent8740533ddf5665846cb5f386625efab2f7462cf7 (diff)
downloadphp-git-f26e77b05fe14e580e982c75887314b7fae7b777.tar.gz
Avoid memcpy UB in streams
Diffstat (limited to 'main/streams')
-rw-r--r--main/streams/streams.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index f1ff923dee..08b8e62014 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -586,7 +586,9 @@ PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size)
stream->readbuf = perealloc(stream->readbuf, stream->readbuflen,
stream->is_persistent);
}
- memcpy(stream->readbuf + stream->writepos, bucket->buf, bucket->buflen);
+ if (bucket->buflen) {
+ memcpy(stream->readbuf + stream->writepos, bucket->buf, bucket->buflen);
+ }
stream->writepos += bucket->buflen;
php_stream_bucket_unlink(bucket);