[lld][MachO] Fix UB after D103006

ubsan detected:
lld/MachO/SyntheticSections.cpp:636:15: runtime error: null pointer
passed as argument 2, which is declared to never be null
This commit is contained in:
Vitaly Buka 2021-06-14 21:15:54 -07:00
parent 79f9cfbc21
commit b01bfdfda6
1 changed files with 2 additions and 1 deletions

View File

@ -633,7 +633,8 @@ void DataInCodeSection::finalizeContents() {
}
void DataInCodeSection::writeTo(uint8_t *buf) const {
memcpy(buf, entries.data(), getRawSize());
if (!entries.empty())
memcpy(buf, entries.data(), getRawSize());
}
FunctionStartsSection::FunctionStartsSection()