Skip to content

Commit

Permalink
automata: Fix broken universal start states with sparse DFA
Browse files Browse the repository at this point in the history
The state IDs were not remapped, which will usually result in an index
out of range error.
  • Loading branch information
ishitatsuyuki committed May 17, 2024
1 parent ddeb85e commit af57064
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions regex-automata/src/dfa/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,14 @@ impl StartTable<Vec<u8>> {
let new_start_id = remap[dfa.to_index(old_start_id)];
sl.set_start(anchored, sty, new_start_id);
}
for ustart in [
&mut sl.universal_start_unanchored,
&mut sl.universal_start_anchored,
] {
if let Some(id) = ustart {
*id = remap[dfa.to_index(*id)];
}
}
Ok(sl)
}
}
Expand Down

0 comments on commit af57064

Please sign in to comment.