[PATCH] D45789: Fix nullptr passed to memcpy in lld/COFF/Chunks.cpp
Bob Haarman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 18 16:33:56 PDT 2018
inglorion created this revision.
inglorion added a reviewer: ruiu.
ubsan found that we sometimes pass nullptr to memcpy in
SectionChunk::writeTo(). This change adds a check that avoids that.
https://reviews.llvm.org/D45789
Files:
lld/COFF/Chunks.cpp
Index: lld/COFF/Chunks.cpp
===================================================================
--- lld/COFF/Chunks.cpp
+++ lld/COFF/Chunks.cpp
@@ -271,6 +271,8 @@
return;
// Copy section contents from source object file to output file.
ArrayRef<uint8_t> A = getContents();
+ if (!A.data())
+ return;
memcpy(Buf + OutputSectionOff, A.data(), A.size());
// Apply relocations.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45789.143027.patch
Type: text/x-patch
Size: 397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180418/12bafced/attachment.bin>
More information about the llvm-commits
mailing list