[lld] 99f0236 - [PDB] Fix ubsan complaint about memcpy from null pointer
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Thu May 27 19:49:24 PDT 2021
Author: Reid Kleckner
Date: 2021-05-27T19:49:09-07:00
New Revision: 99f023656b785b79253dd1ddae6aa2f822180aab
URL: https://github.com/llvm/llvm-project/commit/99f023656b785b79253dd1ddae6aa2f822180aab
DIFF: https://github.com/llvm/llvm-project/commit/99f023656b785b79253dd1ddae6aa2f822180aab.diff
LOG: [PDB] Fix ubsan complaint about memcpy from null pointer
Added:
Modified:
lld/COFF/DebugTypes.cpp
Removed:
################################################################################
diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 69b031e9a2d5..bda9b7728d95 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -594,6 +594,8 @@ void TpiSource::loadGHashes() {
// memory usage.
void TpiSource::assignGHashesFromVector(
std::vector<GloballyHashedType> &&hashVec) {
+ if (hashVec.empty())
+ return;
GloballyHashedType *hashes = new GloballyHashedType[hashVec.size()];
memcpy(hashes, hashVec.data(), hashVec.size() * sizeof(GloballyHashedType));
ghashes = makeArrayRef(hashes, hashVec.size());
More information about the llvm-commits
mailing list