Skip to content

Commit f348b62

Browse files
committed
Check buffer size when writing frames
1 parent bdcda92 commit f348b62

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/encoder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ impl<W: Write> Encoder<W> {
172172
///
173173
/// Note: This function also writes a control extension if necessary.
174174
pub fn write_frame(&mut self, frame: &Frame<'_>) -> Result<(), EncodingError> {
175+
if frame.buffer.len() < usize::from(frame.width) * usize::from(frame.height) {
176+
return Err(io::Error::new(io::ErrorKind::InvalidInput, "frame.buffer is too small for its width/height").into());
177+
}
175178
self.write_frame_header(frame)?;
176179
self.write_image_block(&frame.buffer)
177180
}

0 commit comments

Comments
 (0)