]> git.lizzy.rs Git - rust.git/blobdiff - library/alloc/src/string.rs
Use `copy_nonoverlapping` to copy `bytes` in `String::insert_bytes`
[rust.git] / library / alloc / src / string.rs
index 93f5fe45cd6aa28de9313f4ca0da20410800a1b1..a34f530762d52fefa3b9ef6e3eba32111217e644 100644 (file)
@@ -1451,7 +1451,7 @@ unsafe fn insert_bytes(&mut self, idx: usize, bytes: &[u8]) {
 
         unsafe {
             ptr::copy(self.vec.as_ptr().add(idx), self.vec.as_mut_ptr().add(idx + amt), len - idx);
-            ptr::copy(bytes.as_ptr(), self.vec.as_mut_ptr().add(idx), amt);
+            ptr::copy_nonoverlapping(bytes.as_ptr(), self.vec.as_mut_ptr().add(idx), amt);
             self.vec.set_len(len + amt);
         }
     }