diff options
| author | Bob Haarman <llvm@inglorion.net> | 2018-04-20 22:16:09 +0000 |
|---|---|---|
| committer | Bob Haarman <llvm@inglorion.net> | 2018-04-20 22:16:09 +0000 |
| commit | 8679a7ecea9b630d7757075e18a4727a5d6a5fa5 (patch) | |
| tree | 8bde25f2c50a21eb52528b728e244b30c21b19c3 /lld/COFF/Chunks.cpp | |
| parent | 106df7dd20c337e5fcd1928c13eb12376a2d0f8d (diff) | |
| download | bcm5719-llvm-8679a7ecea9b630d7757075e18a4727a5d6a5fa5.tar.gz bcm5719-llvm-8679a7ecea9b630d7757075e18a4727a5d6a5fa5.zip | |
Fix nullptr passed to memcpy in lld/COFF/Chunks.cpp
Summary:
ubsan found that we sometimes pass nullptr to memcpy in
SectionChunk::writeTo(). This change adds a check that avoids that.
Reviewers: ruiu
Reviewed By: ruiu
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D45789
llvm-svn: 330490
Diffstat (limited to 'lld/COFF/Chunks.cpp')
| -rw-r--r-- | lld/COFF/Chunks.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp index a462caa754b..6d8a0c7c1f4 100644 --- a/lld/COFF/Chunks.cpp +++ b/lld/COFF/Chunks.cpp @@ -271,7 +271,8 @@ void SectionChunk::writeTo(uint8_t *Buf) const { return; // Copy section contents from source object file to output file. ArrayRef<uint8_t> A = getContents(); - memcpy(Buf + OutputSectionOff, A.data(), A.size()); + if (!A.empty()) + memcpy(Buf + OutputSectionOff, A.data(), A.size()); // Apply relocations. size_t InputSize = getSize(); |

