1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +03:00

termwiz: avoid panic for some malformed escapes

This commit is contained in:
Wez Furlong 2020-11-06 13:59:04 -08:00
parent 1dfc06febb
commit b860c9dbda

View File

@ -1679,23 +1679,23 @@ impl<'a> CSIParser<'a> {
}
fn dec(&mut self, params: &'a [i64]) -> Result<DecPrivateMode, ()> {
match FromPrimitive::from_i64(params[0]) {
let p0 = *params.get(0).ok_or_else(|| ())?;
match FromPrimitive::from_i64(p0) {
None => Ok(self.advance_by(
1,
params,
DecPrivateMode::Unspecified(params[0].to_u16().ok_or(())?),
DecPrivateMode::Unspecified(p0.to_u16().ok_or(())?),
)),
Some(mode) => Ok(self.advance_by(1, params, DecPrivateMode::Code(mode))),
}
}
fn terminal_mode(&mut self, params: &'a [i64]) -> Result<TerminalMode, ()> {
match FromPrimitive::from_i64(params[0]) {
None => Ok(self.advance_by(
1,
params,
TerminalMode::Unspecified(params[0].to_u16().ok_or(())?),
)),
let p0 = *params.get(0).ok_or_else(|| ())?;
match FromPrimitive::from_i64(p0) {
None => {
Ok(self.advance_by(1, params, TerminalMode::Unspecified(p0.to_u16().ok_or(())?)))
}
Some(mode) => Ok(self.advance_by(1, params, TerminalMode::Code(mode))),
}
}