Skip to content

Commit faef6a3

Browse files
committed
Copy undef_masks correctly for repeated bytes
1 parent 84fe0c4 commit faef6a3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/librustc_mir/interpret/memory.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
666666
}
667667
}
668668

669-
self.copy_undef_mask(src, dest, size * length)?;
669+
self.copy_undef_mask(src, dest, size, length)?;
670670
// copy back the relocations
671671
self.get_mut(dest.alloc_id)?.relocations.insert_presorted(relocations);
672672

@@ -887,6 +887,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
887887
src: Pointer,
888888
dest: Pointer,
889889
size: Size,
890+
repeat: u64,
890891
) -> EvalResult<'tcx> {
891892
// The bits have to be saved locally before writing to dest in case src and dest overlap.
892893
assert_eq!(size.bytes() as usize as u64, size.bytes());
@@ -896,10 +897,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
896897

897898
for i in 0..size.bytes() {
898899
let defined = undef_mask.get(src.offset + Size::from_bytes(i));
899-
dest_allocation.undef_mask.set(
900-
dest.offset + Size::from_bytes(i),
901-
defined
902-
);
900+
901+
for j in 0..repeat {
902+
dest_allocation.undef_mask.set(
903+
dest.offset + Size::from_bytes(i + (size.bytes() * j)),
904+
defined
905+
);
906+
}
903907
}
904908

905909
Ok(())

0 commit comments

Comments
 (0)