[PATCH] D146382: [NFC] Change strcpy to std::copy

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 01:44:32 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd9b3a9442530: [NFC] Change strcpy to std::copy (authored by 1lyasm, committed by nikic).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146382/new/

https://reviews.llvm.org/D146382

Files:
  llvm/lib/Object/COFFImportFile.cpp


Index: llvm/lib/Object/COFFImportFile.cpp
===================================================================
--- llvm/lib/Object/COFFImportFile.cpp
+++ llvm/lib/Object/COFFImportFile.cpp
@@ -86,7 +86,8 @@
 
   for (const auto &S : Strings) {
     B.resize(Pos + S.length() + 1);
-    strcpy(reinterpret_cast<char *>(&B[Pos]), S.c_str());
+    std::copy(S.begin(), S.end(), std::next(B.begin(), Pos));
+    B[Pos + S.length()] = 0;
     Pos += S.length() + 1;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146382.506871.patch
Type: text/x-patch
Size: 467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230321/b1c6a8ce/attachment.bin>


More information about the llvm-commits mailing list