diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp --- a/llvm/lib/Object/WindowsResource.cpp +++ b/llvm/lib/Object/WindowsResource.cpp @@ -722,7 +722,9 @@ 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); + memcpy(Dest, Src.data(), Src.size()); + if(Src.size() < COFF::NameSize) + Dest[Src.size()] = '\0'; } void WindowsResourceCOFFWriter::writeCOFFHeader(uint32_t TimeDateStamp) {