Skip to content

Commit

Permalink
Debug assert zero-sized frames
Browse files Browse the repository at this point in the history
Fixes #135
  • Loading branch information
kornelski committed Jan 12, 2024
1 parent 12f920f commit 2d63151
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Other changes:
- Enforced memory limit also on metadata extension blocks, and added out-of-memory checks where possible.
- `EncodingFormatError` enum is public.
- Removed defunct `skip_extensions`
- Added validation of frame dimensions. The buffer must be large enough for all pixels,
and if the width or height is 0, the buffer must be empty.

# v0.12.0

Expand Down
1 change: 1 addition & 0 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ impl<W: Write> Encoder<W> {
if frame.buffer.len() < usize::from(frame.width) * usize::from(frame.height) {
return Err(io::Error::new(io::ErrorKind::InvalidInput, "frame.buffer is too small for its width/height").into());
}
debug_assert!((frame.width > 0 && frame.height > 0) || frame.buffer.is_empty(), "the frame has 0 pixels, but non-empty buffer");
self.write_frame_header(frame)?;
self.write_image_block(&frame.buffer)
}
Expand Down

0 comments on commit 2d63151

Please sign in to comment.