[librsvg: 4/14] utf8_cstr(): Don't do UTF-8 validation (!) Libxml2 does it for us.
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/14] utf8_cstr(): Don't do UTF-8 validation (!) Libxml2 does it for us.
- Date: Wed, 24 Jan 2018 19:07:31 +0000 (UTC)
commit 242d271f8f246868a2dad4362a2ad2da55087609
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Jan 24 12:42:31 2018 -0600
utf8_cstr(): Don't do UTF-8 validation (!) Libxml2 does it for us.
rust/src/util.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/rust/src/util.rs b/rust/src/util.rs
index 9f33f67..f0b62aa 100644
--- a/rust/src/util.rs
+++ b/rust/src/util.rs
@@ -1,6 +1,7 @@
use libc;
use std::ffi::CStr;
+use std::str;
// In paint servers (patterns, gradients, etc.), we have an
// Option<String> for fallback names. This is a utility function to
@@ -28,5 +29,5 @@ pub fn double_equals (a: f64, b: f64) -> bool {
pub unsafe fn utf8_cstr<'a>(s: *const libc::c_char) -> &'a str {
assert!(!s.is_null());
- CStr::from_ptr(s).to_str().unwrap()
+ str::from_utf8_unchecked(CStr::from_ptr(s).to_bytes())
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]