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,6 +26,7 @@ uint64_t InputSection::getFileOffset() const {
|
|||
}
|
||||
|
||||
void InputSection::writeTo(uint8_t *buf) {
|
||||
if (!data.empty())
|
||||
memcpy(buf, data.data(), data.size());
|
||||
|
||||
for (Reloc &r : relocs) {
|
||||
|
|
Loading…
Reference in New Issue