diff --git a/src/types/value_ref.rs b/src/types/value_ref.rs index 503f905..80d2457 100644 --- a/src/types/value_ref.rs +++ b/src/types/value_ref.rs @@ -126,8 +126,6 @@ where impl<'a> ValueRef<'a> { pub(crate) unsafe fn from_value(value: *mut crate::ffi::sqlite3_value) -> ValueRef<'a> { use crate::ffi; - use std::ffi::CStr; - use std::os::raw::c_char; use std::slice::from_raw_parts; match ffi::sqlite3_value_type(value) { @@ -136,13 +134,12 @@ impl<'a> ValueRef<'a> { ffi::SQLITE_FLOAT => ValueRef::Real(ffi::sqlite3_value_double(value)), ffi::SQLITE_TEXT => { let text = ffi::sqlite3_value_text(value); + let len = ffi::sqlite3_value_bytes(value); assert!( !text.is_null(), "unexpected SQLITE_TEXT value type with NULL data" ); - let s = CStr::from_ptr(text as *const c_char); - - let s = s.to_bytes(); + let s = from_raw_parts(text as *const u8, len as usize); ValueRef::Text(s) } ffi::SQLITE_BLOB => {