[lld] b01bfdf - [lld][MachO] Fix UB after D103006
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 14 21:22:26 PDT 2021
Author: Vitaly Buka
Date: 2021-06-14T21:15:54-07:00
New Revision: b01bfdfda64b684965cd7f97e99e4b0bce5d67fa
URL: https://github.com/llvm/llvm-project/commit/b01bfdfda64b684965cd7f97e99e4b0bce5d67fa
DIFF: https://github.com/llvm/llvm-project/commit/b01bfdfda64b684965cd7f97e99e4b0bce5d67fa.diff
LOG: [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
Added:
Modified:
lld/MachO/SyntheticSections.cpp
Removed:
################################################################################
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 458bbaa289f4..ef84a9d7c0e8 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -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()
More information about the llvm-commits
mailing list