[PATCH] D26638: Don't pass nullptr into memcpy
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 14:10:25 PST 2016
vitalybuka created this revision.
vitalybuka added reviewers: rnk, zturner.
vitalybuka added a subscriber: llvm-commits.
It's undefined according UBSAN.
Not sure which CL caused test failures, but seems writeBytes for empty buffer
should be OK.
https://reviews.llvm.org/D26638
Files:
include/llvm/DebugInfo/MSF/ByteStream.h
Index: include/llvm/DebugInfo/MSF/ByteStream.h
===================================================================
--- include/llvm/DebugInfo/MSF/ByteStream.h
+++ include/llvm/DebugInfo/MSF/ByteStream.h
@@ -97,7 +97,8 @@
return make_error<MSFError>(msf_error_code::insufficient_buffer);
uint8_t *DataPtr = const_cast<uint8_t *>(Data.data());
- ::memcpy(DataPtr + Offset, Buffer.data(), Buffer.size());
+ if (!Buffer.empty())
+ ::memcpy(DataPtr + Offset, Buffer.data(), Buffer.size());
return Error::success();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26638.77886.patch
Type: text/x-patch
Size: 547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161114/61ae5732/attachment.bin>
More information about the llvm-commits
mailing list