Skip to content

Commit d8530d0

Browse files
Use copy_nonoverlapping to copy bytes in String::insert_bytes
1 parent 966361f commit d8530d0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/alloc/src/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ impl String {
14511451

14521452
unsafe {
14531453
ptr::copy(self.vec.as_ptr().add(idx), self.vec.as_mut_ptr().add(idx + amt), len - idx);
1454-
ptr::copy(bytes.as_ptr(), self.vec.as_mut_ptr().add(idx), amt);
1454+
ptr::copy_nonoverlapping(bytes.as_ptr(), self.vec.as_mut_ptr().add(idx), amt);
14551455
self.vec.set_len(len + amt);
14561456
}
14571457
}

0 commit comments

Comments
 (0)