[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:
Shoaib Meenai 2020-04-28 11:29:30 -07:00
parent 1b56980845
commit af40bff32d
1 changed files with 2 additions and 1 deletions

View File

@ -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) {