forge
Explore
Log in

Don't you dare go Hollow

tty: Add check for zero gamma size

Browse files at this commit

a7b38192142440c59a4e793cf5de99b9a7f1c2c3Ivan MolodetskikhParent: 1eff5ae
src/backend/tty.rsmodified+2 -0
@@ -2074,6 +2074,8 @@ pub fn set_gamma_for_crtc(
20742074 let info = device.get_crtc(crtc).context("error getting crtc info")?;
20752075 let gamma_length = info.gamma_length() as usize;
20762076
2077+ ensure!(gamma_length != 0, "setting gamma is not supported");
2078+
20772079 let mut temp;
20782080 let ramp = if let Some(ramp) = ramp {
20792081 ensure!(ramp.len() == gamma_length * 3, "wrong gamma length");
src/handlers/mod.rsmodified+1 -0
@@ -448,6 +448,7 @@ impl GammaControlHandler for State {
448448
449449 fn get_gamma_size(&mut self, output: &Output) -> Option<u32> {
450450 match self.backend.tty().get_gamma_size(output) {
451+ Ok(0) => None, // Setting gamma is not supported.
451452 Ok(size) => Some(size),
452453 Err(err) => {
453454 warn!(