summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Krasin <krasin@chromium.org>2016-08-31 17:23:05 +0000
committerIvan Krasin <krasin@chromium.org>2016-08-31 17:23:05 +0000
commit8baccc2f19941dd8ec5a6d89e848fd49d5f66d80 (patch)
tree38d4eeea293c35210be06476789e746aa3ef0086
parent1e9d3d3b40ccf8c46ae8cd5ee30e9dfbf6bd6604 (diff)
downloadbcm5719-llvm-8baccc2f19941dd8ec5a6d89e848fd49d5f66d80.tar.gz
bcm5719-llvm-8baccc2f19941dd8ec5a6d89e848fd49d5f66d80.zip
Fix UBSan bot by not passing NULL into memcpy src.
Summary: UBSan complains like the following: tools/lld/COFF/Writer.cpp:97:15: runtime error: null pointer passed as argument 2, which is declared to never be null The reason is that the vector could be empty. Reviewers: rsmith Subscribers: Eugene.Zelenko, kcc Differential Revision: https://reviews.llvm.org/D24050 llvm-svn: 280259
-rw-r--r--lld/COFF/Writer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 6c3a7bdb848..4e66076ffcb 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -93,7 +93,8 @@ class CVDebugRecordChunk : public Chunk {
// variable sized field (PDB Path)
auto *P = reinterpret_cast<char *>(B + OutputSectionOff + sizeof(*R));
- memcpy(P, Config->PDBPath.data(), Config->PDBPath.size());
+ if (!Config->PDBPath.empty())
+ memcpy(P, Config->PDBPath.data(), Config->PDBPath.size());
P[Config->PDBPath.size()] = '\0';
}
};
OpenPOWER on IntegriCloud