Don't pass nullptr into memcpy

Summary:
It's undefined according UBSAN.
Not sure which CL caused test failures, but seems writeBytes for empty buffer
should be OK.

Reviewers: rnk, zturner

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D26638

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286896 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vitaly Buka 2016-11-14 22:05:19 +00:00
parent 107362cf5f
commit 5ffd1d01cc

View File

@ -91,6 +91,9 @@ public:
uint32_t getLength() const override { return ImmutableStream.getLength(); }
Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Buffer) const override {
if (Buffer.empty())
return Error::success();
if (Data.size() < Buffer.size())
return make_error<MSFError>(msf_error_code::insufficient_buffer);
if (Offset > Buffer.size() - Data.size())