Skip to content

Commit

Permalink
graphics/image: Turn multiple bmp planes into a hard error
Browse files Browse the repository at this point in the history
Previously, we only emitted a warning but the spec explicitly
states that this field should always be zero.
  • Loading branch information
simonwuelker committed Feb 16, 2024
1 parent 6757ea8 commit f5b71b0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/graphics/image/src/bmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum Error {
PaletteTooLarge,
NegativeWidth,
InvalidCompressionForFormat,
MultiplePlanes,

/// This image contains extreme values and cannot be parsed
///
Expand Down Expand Up @@ -166,7 +167,8 @@ impl InfoHeader {
.ok_or(Error::UnexpectedEndOfFile)?;

if planes != 1 {
log::warn!("Unexpected number of planes, expected 1, got {planes:?}");
log::error!("Unexpected number of planes, expected 1, got {planes:?}");
return Err(Error::MultiplePlanes);
}

let bits_per_pixel = byte_stream
Expand Down

0 comments on commit f5b71b0

Please sign in to comment.