Skip to content

Commit eab5b61

Browse files
committed
automata: add regression test for dense::DFA::from_bytes validation panic
1 parent a76e0a0 commit eab5b61

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

regex-automata/src/dfa/dense.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5230,4 +5230,17 @@ mod tests {
52305230
let got = dfa.try_search_rev(&input);
52315231
assert_eq!(Err(expected), got);
52325232
}
5233+
5234+
// This panics in TransitionTable::validate if the match states are not validated first.
5235+
#[test]
5236+
fn regression_validation_order() {
5237+
let mut dfa = DFA::new("abc").unwrap();
5238+
dfa.ms = MatchStates {
5239+
slices: vec![],
5240+
pattern_ids: vec![],
5241+
pattern_len: 1,
5242+
};
5243+
let (buf, _) = dfa.to_bytes_native_endian();
5244+
DFA::from_bytes(&buf).unwrap_err();
5245+
}
52335246
}

0 commit comments

Comments
 (0)