From 4d3f4ec7e4f3fcdfebf885a76226861f0cf5cb8f Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 27 Jun 2025 07:38:12 +0200 Subject: [PATCH] hwdec-vaapi: handle copying data into kodaed chroma planes For, say, 720x408 frame hardware decoder may report chroma plane width as 368 while destination frame chroma width is merely 360. Assuming width <= stride leads to panic during copying. --- hwdec-vaapi/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hwdec-vaapi/src/lib.rs b/hwdec-vaapi/src/lib.rs index 3e23a46..9dca7b1 100644 --- a/hwdec-vaapi/src/lib.rs +++ b/hwdec-vaapi/src/lib.rs @@ -348,10 +348,11 @@ fn copy_luma(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize, w: usiz ); } } else { + let copy_len = dstride.min(w); for (dline, sline) in dst.chunks_mut(dstride) .zip(src.chunks(sstride)) .take(h) { - dline[..w].copy_from_slice(&sline[..w]); + dline[..copy_len].copy_from_slice(&sline[..copy_len]); } } } -- 2.39.5