[llvm] r286896 - Don't pass nullptr into memcpy
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 14:05:19 PST 2016
Author: vitalybuka
Date: Mon Nov 14 16:05:19 2016
New Revision: 286896
URL: http://llvm.org/viewvc/llvm-project?rev=286896&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/DebugInfo/MSF/ByteStream.h
Modified: llvm/trunk/include/llvm/DebugInfo/MSF/ByteStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/MSF/ByteStream.h?rev=286896&r1=286895&r2=286896&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/MSF/ByteStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/MSF/ByteStream.h Mon Nov 14 16:05:19 2016
@@ -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())
More information about the llvm-commits
mailing list