Skip to content

Commit

Permalink
fix going beyond end of useful data in rgbas array
Browse files Browse the repository at this point in the history
It is possible for rgbas to be an array with bigger allocated size, with garbage data in the end - make sure to only take the useful data.
  • Loading branch information
maximbaz committed Feb 1, 2022
1 parent 3901acc commit e47933f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub fn compute_perceived_lightness_percent(rgbas: &[u8], has_alpha: bool, pixels

let (rs, gs, bs) = rgbas
.iter()
.take(channels * pixels)
.chunks(channels)
.into_iter()
.map(|mut chunk| {
Expand Down

0 comments on commit e47933f

Please sign in to comment.