aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/event.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2023-09-17 11:04:05 +0200
committerGitHub <noreply@github.com>2023-09-17 13:04:05 +0400
commite35e5ad14fce8456afdd89f2b392b9924bb27471 (patch)
treeb4ba4f415457eecf618fc25fd6ce8a4a295b2bf3 /alacritty/src/event.rs
parent77aa9f42bac4377efe26512d71098d21b9b547fd (diff)
downloadr-alacritty-e35e5ad14fce8456afdd89f2b392b9924bb27471.tar.gz
r-alacritty-e35e5ad14fce8456afdd89f2b392b9924bb27471.tar.bz2
r-alacritty-e35e5ad14fce8456afdd89f2b392b9924bb27471.zip
Fix regex memory usage
This fixes an issue where regexes with a large number of possible states would consume excessive memory, since the entire DFA was compiled ahead of time. To solve this, the DFA is now built at runtime using `regex-automata`'s hybrid DFA. There are however still some checks performed ahead of time, causing errors with obscenely large regexes (`[0-9A-Za-z]{999999999}`), which shouldn't cause any issues. A regex which is large, but not large enough to fail the NFA construction (like `[0-9A-Za-z]{999999}`) will cause a long search of the entire grid, but will complete and show the match. Closes #7097.
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r--alacritty/src/event.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index 387e768e..1b7e280c 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -154,8 +154,8 @@ impl SearchState {
}
/// Active search dfas.
- pub fn dfas(&self) -> Option<&RegexSearch> {
- self.dfas.as_ref()
+ pub fn dfas(&mut self) -> Option<&mut RegexSearch> {
+ self.dfas.as_mut()
}
/// Search regex text if a search is active.
@@ -637,7 +637,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
fn search_next(&mut self, origin: Point, direction: Direction, side: Side) -> Option<Match> {
self.search_state
.dfas
- .as_ref()
+ .as_mut()
.and_then(|dfas| self.terminal.search_next(dfas, origin, direction, side, None))
}
@@ -913,7 +913,7 @@ impl<'a, N: Notify + 'a, T: EventListener> ActionContext<'a, N, T> {
/// Jump to the first regex match from the search origin.
fn goto_match(&mut self, mut limit: Option<usize>) {
- let dfas = match &self.search_state.dfas {
+ let dfas = match &mut self.search_state.dfas {
Some(dfas) => dfas,
None => return,
};