[PATCH] D74666: Prevent gcc from issuing a warning upon coffnamecpy
serge via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 07:21:15 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG498a6136a271: Prevent gcc from issuing a warning upon coffnamecpy (authored by serge-sans-paille).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74666/new/
https://reviews.llvm.org/D74666
Files:
llvm/lib/Object/WindowsResource.cpp
Index: llvm/lib/Object/WindowsResource.cpp
===================================================================
--- llvm/lib/Object/WindowsResource.cpp
+++ llvm/lib/Object/WindowsResource.cpp
@@ -721,8 +721,10 @@
// it's okay to *not* copy the trailing zero.
static void coffnamecpy(char (&Dest)[COFF::NameSize], StringRef Src) {
assert(Src.size() <= COFF::NameSize &&
- "Src is not larger than COFF::NameSize");
- strncpy(Dest, Src.data(), (size_t)COFF::NameSize);
+ "Src is larger than COFF::NameSize");
+ assert((Src.size() == COFF::NameSize || Dest[Src.size()] == '\0') &&
+ "Dest not zeroed upon initialization");
+ memcpy(Dest, Src.data(), Src.size());
}
void WindowsResourceCOFFWriter::writeCOFFHeader(uint32_t TimeDateStamp) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74666.245162.patch
Type: text/x-patch
Size: 770 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200218/2d981714/attachment-0001.bin>
More information about the llvm-commits
mailing list