tty: Add check for zero gamma size
Browse files at this commita7b38192142440c59a4e793cf5de99b9a7f1c2c3Parent: 1eff5ae2 changed files +3 -0
- src/backend/tty.rs +2 -0
- src/handlers/mod.rs +1 -0
src/backend/tty.rsmodified+2 -0
| @@ -2074,6 +2074,8 @@ pub fn set_gamma_for_crtc( | |||
| 2074 | let info = device.get_crtc(crtc).context("error getting crtc info")?; | 2074 | let info = device.get_crtc(crtc).context("error getting crtc info")?; |
| 2075 | let gamma_length = info.gamma_length() as usize; | 2075 | let gamma_length = info.gamma_length() as usize; |
| 2076 | 2076 | ||
| 2077 | + ensure!(gamma_length != 0, "setting gamma is not supported"); | ||
| 2078 | + | ||
| 2077 | let mut temp; | 2079 | let mut temp; |
| 2078 | let ramp = if let Some(ramp) = ramp { | 2080 | let ramp = if let Some(ramp) = ramp { |
| 2079 | ensure!(ramp.len() == gamma_length * 3, "wrong gamma length"); | 2081 | ensure!(ramp.len() == gamma_length * 3, "wrong gamma length"); |
src/handlers/mod.rsmodified+1 -0
| @@ -448,6 +448,7 @@ impl GammaControlHandler for State { | |||
| 448 | 448 | ||
| 449 | fn get_gamma_size(&mut self, output: &Output) -> Option<u32> { | 449 | fn get_gamma_size(&mut self, output: &Output) -> Option<u32> { |
| 450 | match self.backend.tty().get_gamma_size(output) { | 450 | match self.backend.tty().get_gamma_size(output) { |
| 451 | + Ok(0) => None, // Setting gamma is not supported. | ||
| 451 | Ok(size) => Some(size), | 452 | Ok(size) => Some(size), |
| 452 | Err(err) => { | 453 | Err(err) => { |
| 453 | warn!( | 454 | warn!( |