]> git.nihav.org Git - nihav.git/commitdiff
nihav_core/scale: copy only the common part of the buffer
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 21 Jan 2026 20:05:13 +0000 (21:05 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 21 Jan 2026 20:05:13 +0000 (21:05 +0100)
For padded pictures strides and offsets may be the same while
overall size differs, leading to panic during copy.

nihav-core/src/scale/mod.rs

index 93d42a4148e374079e458ab73326a64cea83524f..85f7b83274854036aecc65b07513b96d99265d21 100644 (file)
@@ -235,7 +235,8 @@ fn copy(pic_in: &NABufferType, pic_out: &mut NABufferType)
         if same {
             let sdata = sbuf.get_data();
             let ddata = dbuf.get_data_mut().unwrap();
-            ddata.copy_from_slice(&sdata[0..]);
+            let copy_len = sdata.len().min(ddata.len());
+            ddata[..copy_len].copy_from_slice(&sdata[..copy_len]);
         } else {
             let sdata = sbuf.get_data();
             for comp in 0..src_components.min(dst_components) {