Skip to content

Commit

Permalink
Fix emacs crashes on invalid utf-8 strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurnevsky committed Dec 17, 2024
1 parent 0b3de01 commit 492b2f4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
7 changes: 6 additions & 1 deletion modules/emacs/fuzzy-matcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ rustPlatform.buildRustPackage {
rm -r $out/lib/
'';

cargoHash = "sha256-YQf85rK4tIVOB10aNpFEZJvLDEPSrr9b/9steMM7ITU=";
cargoLock = {
lockFile = ./fuzzy-matcher/Cargo.lock;
outputHashes = {
"emacs-0.19.0" = "sha256-094GLODTvUpwjs77KTsAYBdytX726c2aNkyOS9sxRuU=";
};
};
}
11 changes: 4 additions & 7 deletions modules/emacs/fuzzy-matcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion modules/emacs/fuzzy-matcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name = "fuzzy_matcher_el"
crate-type = ["cdylib"]

[dependencies]
emacs = "0.19"
emacs = { git = "https://github.com/kurnevsky/emacs-module-rs.git", rev = "297bdd761b3c827d9387708330f3cef62edd7be8" }
nucleo-matcher = "0.3"
lazy_static = "1.5"

Expand Down
12 changes: 11 additions & 1 deletion modules/emacs/fuzzy-matcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ lazy_static! {
}

#[defun]
fn fuzzy_indices(env: &Env, pattern: String, source: String) -> Result<Option<Value>> {
fn fuzzy_indices<'a>(env: &'a Env, pattern: Value<'a>, source: Value<'a>) -> Result<Option<Value<'a>>> {
let pattern: String = if let Ok(pattern) = pattern.into_rust() {
pattern
} else {
return Ok(None);
};
let source: String = if let Ok(source) = source.into_rust() {
source
} else {
return Ok(None);
};
let mut indices = Vec::new();
let mut source_buf = Vec::new();
let mut pattern_buf = Vec::new();
Expand Down

0 comments on commit 492b2f4

Please sign in to comment.