From 49665c9ae23b19711fc41e15ac526755f6a48072 Mon Sep 17 00:00:00 2001 From: Evgeny Kurnevsky Date: Tue, 17 Dec 2024 17:08:48 +0100 Subject: [PATCH] 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. --- src/types/string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/string.rs b/src/types/string.rs index 5c1099c..7808b69 100644 --- a/src/types/string.rs +++ b/src/types/string.rs @@ -13,7 +13,7 @@ impl FromLisp<'_> for String { #[cfg(feature = "utf-8-validation")] fn from_lisp(value: Value<'_>) -> Result { let bytes = value.env.string_bytes(value)?; - Ok(String::from_utf8(bytes).unwrap()) + String::from_utf8(bytes).map_err(|e| e.into()) } }