forked from OSchip/llvm-project
Avoid memcpy from nullptr. NFC.
This was caught by the UBSan bot. When the atom has no size, we would issue a memcpy with size0 and a nullptr for the source. Also, this code should never have references inside an empty atom so add an assert for that while we're here. llvm-svn: 264115
This commit is contained in:
parent
8e1b9a17a6
commit
b9a9d7163f
|
@ -420,6 +420,11 @@ void ArchHandler_x86::generateAtomContent(const DefinedAtom &atom,
|
|||
FindAddressForAtom findSectionAddress,
|
||||
uint64_t imageBaseAddress,
|
||||
uint8_t *atomContentBuffer) {
|
||||
if (!atom.size()) {
|
||||
assert(atom.begin() == atom.end() &&
|
||||
"Cannot have references without content");
|
||||
return;
|
||||
}
|
||||
// Copy raw bytes.
|
||||
memcpy(atomContentBuffer, atom.rawContent().data(), atom.size());
|
||||
// Apply fix-ups.
|
||||
|
|
Loading…
Reference in New Issue