[llvm-branch-commits] [lld] 791fe7a - [lld-macho] Fix memcpy ub after D93267
Fangrui Song via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Dec 20 20:05:33 PST 2020
Author: Fangrui Song
Date: 2020-12-20T20:01:20-08:00
New Revision: 791fe7ac57a9b660554219a99d63e07abfaa0982
URL: https://github.com/llvm/llvm-project/commit/791fe7ac57a9b660554219a99d63e07abfaa0982
DIFF: https://github.com/llvm/llvm-project/commit/791fe7ac57a9b660554219a99d63e07abfaa0982.diff
LOG: [lld-macho] Fix memcpy ub after D93267
Added:
Modified:
lld/MachO/UnwindInfoSection.cpp
Removed:
################################################################################
diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp
index acb4a9d69b79..b4c3a31f8565 100644
--- a/lld/MachO/UnwindInfoSection.cpp
+++ b/lld/MachO/UnwindInfoSection.cpp
@@ -318,8 +318,9 @@ void UnwindInfoSection::writeTo(uint8_t *buf) const {
*ep++ = (it->second << COMPRESSED_ENTRY_FUNC_OFFSET_BITS) |
(cuep->functionAddress - functionAddressBase);
}
- memcpy(ep, page.localEncodings.data(),
- page.localEncodings.size() * sizeof(uint32_t));
+ if (page.localEncodings.size() != 0)
+ memcpy(ep, page.localEncodings.data(),
+ page.localEncodings.size() * sizeof(uint32_t));
} else {
auto *p2p =
reinterpret_cast<unwind_info_regular_second_level_page_header *>(pp);
More information about the llvm-branch-commits
mailing list