1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-26 08:25:50 +03:00

fix UB in vtparse

closes: #1631
This commit is contained in:
Wez Furlong 2022-02-10 08:13:37 -07:00
parent 3316695dc0
commit 41342ef740
2 changed files with 17 additions and 4 deletions

View File

@ -29,12 +29,21 @@ fn lookup(state: State, b: u8) -> (Action, State) {
}
#[inline(always)]
#[cfg(not(test))]
fn lookup_entry(state: State) -> Action {
unsafe { *ENTRY.get_unchecked(state as usize) }
}
#[inline(always)]
#[cfg(debug_assertions)]
#[cfg(test)]
fn lookup_entry(state: State) -> Action {
*ENTRY
.get(state as usize)
.unwrap_or_else(|| panic!("State {:?} has no entry in ENTRY", state))
}
#[inline(always)]
#[cfg(test)]
fn lookup_exit(state: State) -> Action {
*EXIT
.get(state as usize)
@ -42,7 +51,7 @@ fn lookup_exit(state: State) -> Action {
}
#[inline(always)]
#[cfg(not(debug_assertions))]
#[cfg(not(test))]
fn lookup_exit(state: State) -> Action {
unsafe { *EXIT.get_unchecked(state as usize) }
}

View File

@ -308,7 +308,7 @@ pub(crate) static TRANSITIONS: [[u16; 256]; 15] = [
define_table!(apc_string),
];
pub(crate) static ENTRY: [Action; 15] = [
pub(crate) static ENTRY: [Action; 17] = [
Action::None, // Ground
Action::Clear, // Escape
Action::None, // EscapeIntermediate
@ -324,9 +324,11 @@ pub(crate) static ENTRY: [Action; 15] = [
Action::OscStart, // OscString
Action::None, // SosPmString
Action::ApcStart, // ApcString
Action::None, // Anywhere
Action::None, // Utf8Sequence
];
pub(crate) static EXIT: [Action; 15] = [
pub(crate) static EXIT: [Action; 17] = [
Action::None, // Ground
Action::None, // Escape
Action::None, // EscapeIntermediate
@ -342,6 +344,8 @@ pub(crate) static EXIT: [Action; 15] = [
Action::OscEnd, // OscString
Action::None, // SosPmString
Action::ApcEnd, // ApcString
Action::None, // Anywhere
Action::None, // Utf8Sequence
];
#[cfg(test)]