diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-31 21:22:58 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-31 21:22:58 +0000 |
commit | 5ffd83dbcc34f10e07f6d3e968ae6365869615f4 (patch) | |
tree | 0e9f5cf729dde39f949698fddef45a34e2bc7f44 /contrib/llvm-project/llvm/lib/Object/WindowsResource.cpp | |
parent | 1799696096df87b52968b8996d00c91e0a5de8d9 (diff) | |
parent | cfca06d7963fa0909f90483b42a6d7d194d01e08 (diff) |
Notes
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Object/WindowsResource.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Object/WindowsResource.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/contrib/llvm-project/llvm/lib/Object/WindowsResource.cpp b/contrib/llvm-project/llvm/lib/Object/WindowsResource.cpp index 10717718b201..2a69c6c46b59 100644 --- a/contrib/llvm-project/llvm/lib/Object/WindowsResource.cpp +++ b/contrib/llvm-project/llvm/lib/Object/WindowsResource.cpp @@ -346,7 +346,7 @@ Error WindowsResourceParser::parse(WindowsResource *WR, ResourceEntryRef Entry = EntryOrErr.get(); uint32_t Origin = InputFilenames.size(); - InputFilenames.push_back(WR->getFileName()); + InputFilenames.push_back(std::string(WR->getFileName())); bool End = false; while (!End) { @@ -368,7 +368,7 @@ Error WindowsResourceParser::parse(ResourceSectionRef &RSR, StringRef Filename, std::vector<std::string> &Duplicates) { UNWRAP_REF_OR_RETURN(BaseTable, RSR.getBaseTable()); uint32_t Origin = InputFilenames.size(); - InputFilenames.push_back(Filename); + InputFilenames.push_back(std::string(Filename)); std::vector<StringOrID> Context; return addChildren(Root, RSR, BaseTable, Origin, Context, Duplicates); } @@ -721,8 +721,10 @@ WindowsResourceCOFFWriter::write(uint32_t TimeDateStamp) { // 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) { |