forked from OSchip/llvm-project
[MachO] Fix UB in memcpy
UBSan complains about a memcpy with a null pointer, so just skip the memcpy call if the data is empty.
This commit is contained in:
parent
1b56980845
commit
af40bff32d
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue