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

Ilyas Mustafazade via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 19 11:19:10 PDT 2023


1lyasm updated this revision to Diff 506410.
1lyasm retitled this revision from "Change strcpy to strncpy" to "Change strcpy to std::copy".
1lyasm added a comment.

Remove strncpy and add std::copy


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.506410.patch
Type: text/x-patch
Size: 467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230319/3344d67f/attachment.bin>


More information about the llvm-commits mailing list