From d8530d0fa31224a2506a0932af5ac18d86c1bb0f Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Fri, 18 Jun 2021 15:14:22 +0200 Subject: [PATCH] Use `copy_nonoverlapping` to copy `bytes` in `String::insert_bytes` --- library/alloc/src/string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 93f5fe45cd6..a34f530762d 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -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); } }