Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add stride check in FFmpeg frame conversion

Richie McIlroyc73f73524ac9
diff --git a/crates/recording/src/screenshot.rs b/crates/recording/src/screenshot.rs
index e72ad4fbf..3c3c02ebc 100644
--- a/crates/recording/src/screenshot.rs
+++ b/crates/recording/src/screenshot.rs
@@ -429,6 +429,16 @@ fn convert_ffmpeg_frame_to_image(frame: &ffmpeg::frame::Video) -> anyhow::Result
let dst_stride = width * 3;
let src_stride = rgb_frame.stride(0);
+ if src_stride < dst_stride {
+ return Err(anyhow!(
+ "Source stride ({}) is less than destination stride ({}); width={}, height={}",
+ src_stride,
+ dst_stride,
+ width,
+ height
+ ));
+ }
+
let mut img_buffer = vec![0u8; height * dst_stride];
for y in 0..height {