about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWesley Wiser <wwiser@gmail.com>2018-06-30 14:23:41 -0400
committerWesley Wiser <wwiser@gmail.com>2018-06-30 15:20:10 -0400
commitfaef6a30e6a470fd46444642c62f4a1ff378ca7f (patch)
tree5c83bd056858010f24a3be2da92f8772841dabf3
parent84fe0c40a1829ebac169a1f7804da4b557b31359 (diff)
downloadrust-faef6a30e6a470fd46444642c62f4a1ff378ca7f.tar.gz
rust-faef6a30e6a470fd46444642c62f4a1ff378ca7f.zip
Copy undef_masks correctly for repeated bytes
-rw-r--r--src/librustc_mir/interpret/memory.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index 8aff58e09ba..bf720540bdc 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -666,7 +666,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
             }
         }
 
-        self.copy_undef_mask(src, dest, size * length)?;
+        self.copy_undef_mask(src, dest, size, length)?;
         // copy back the relocations
         self.get_mut(dest.alloc_id)?.relocations.insert_presorted(relocations);
 
@@ -887,6 +887,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
         src: Pointer,
         dest: Pointer,
         size: Size,
+        repeat: u64,
     ) -> EvalResult<'tcx> {
         // The bits have to be saved locally before writing to dest in case src and dest overlap.
         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> {
 
         for i in 0..size.bytes() {
             let defined = undef_mask.get(src.offset + Size::from_bytes(i));
-            dest_allocation.undef_mask.set(
-                dest.offset + Size::from_bytes(i),
-                defined
-            );
+            
+            for j in 0..repeat {
+                dest_allocation.undef_mask.set(
+                    dest.offset + Size::from_bytes(i + (size.bytes() * j)),
+                    defined
+                );
+            }
         }
 
         Ok(())