We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b31f28a commit fbe8cbfCopy full SHA for fbe8cbf
src/lib.rs
@@ -273,12 +273,11 @@ macro_rules! ortsys {
273
pub(crate) use ortsys;
274
275
pub(crate) fn char_p_to_string(raw: *const c_char) -> Result<String> {
276
- let c_string = unsafe { CStr::from_ptr(raw.cast_mut()).to_owned() };
277
- match c_string.into_string() {
278
- Ok(string) => Ok(string),
279
- Err(e) => Err(Error::wrap(e))
+ if raw.is_null() {
+ return Ok(String::new());
280
}
281
- .map_err(Error::wrap)
+ let c_string = unsafe { CStr::from_ptr(raw.cast_mut()).to_owned() };
+ Ok(c_string.to_string_lossy().to_string())
282
283
284
pub(crate) struct PrivateTraitMarker;
0 commit comments