[lld] r280259 - Fix UBSan bot by not passing NULL into memcpy src.
Ivan Krasin via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 31 10:23:05 PDT 2016
Author: krasin
Date: Wed Aug 31 12:23:05 2016
New Revision: 280259
URL: http://llvm.org/viewvc/llvm-project?rev=280259&view=rev
Log:
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
Modified:
lld/trunk/COFF/Writer.cpp
Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=280259&r1=280258&r2=280259&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Wed Aug 31 12:23:05 2016
@@ -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';
}
};
More information about the llvm-commits
mailing list