projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1b56980
)
[MachO] Fix UB in memcpy
author
Shoaib Meenai
<smeenai@fb.com>
Tue, 28 Apr 2020 18:29:30 +0000
(11:29 -0700)
committer
Shoaib Meenai
<smeenai@fb.com>
Tue, 28 Apr 2020 18:33:54 +0000
(11:33 -0700)
UBSan complains about a memcpy with a null pointer, so just skip the
memcpy call if the data is empty.
lld/MachO/InputSection.cpp
patch
|
blob
|
history
diff --git
a/lld/MachO/InputSection.cpp
b/lld/MachO/InputSection.cpp
index
76cf874
..
8c4a50b
100644
(file)
--- a/
lld/MachO/InputSection.cpp
+++ b/
lld/MachO/InputSection.cpp
@@
-26,7
+26,8
@@
uint64_t InputSection::getFileOffset() const {
}
void InputSection::writeTo(uint8_t *buf) {
- memcpy(buf, data.data(), data.size());
+ if (!data.empty())
+ memcpy(buf, data.data(), data.size());
for (Reloc &r : relocs) {
uint64_t va = 0;