Skip to content

Commit dd6fec5

Browse files
committed
Fix crashes with invalid utf-8.
According to the discussion in emacs bug#74922 it's possible that emacs passes invalid strings to dynamic libraries.
1 parent 126241a commit dd6fec5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ emacs-macros = { path = "emacs-macros", version = "0.17.0" }
3434
rustc_version = "0.2.3"
3535

3636
[features]
37-
default = []
37+
default = [ "utf-8-validation" ]
3838
utf-8-validation = []
3939
lossy-integer-conversion = []
4040
nonzero-integer-conversion = []

src/types/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl FromLisp<'_> for String {
1313
#[cfg(feature = "utf-8-validation")]
1414
fn from_lisp(value: Value<'_>) -> Result<Self> {
1515
let bytes = value.env.string_bytes(value)?;
16-
Ok(String::from_utf8(bytes).unwrap())
16+
String::from_utf8(bytes).map_err(|e| e.into())
1717
}
1818
}
1919

0 commit comments

Comments
 (0)