Skip to content

Commit 4bff859

Browse files
committed
fix: remove null terminator
1 parent 60c4e1e commit 4bff859

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/services/windows.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -912,19 +912,16 @@ fn get_device_property<T: Default>(
912912
}
913913

914914
fn parse_str(buffer: &[u8]) -> Result<String, FfiError> {
915-
Ok(HSTRING::from_wide(to_u16_slice(buffer))
915+
let slice = to_u16_slice(buffer);
916+
Ok(HSTRING::from_wide(&slice[0..slice.len() - 1])
916917
.into_report()
917918
.change_context(FfiError::Parser)
918919
.attach_printable("failed to parse string")?
919920
.to_string())
920921
}
921922

922923
fn parse_uuid(buffer: &[u8]) -> Result<Uuid, FfiError> {
923-
let string = HSTRING::from_wide(to_u16_slice(buffer))
924-
.into_report()
925-
.change_context(FfiError::Parser)
926-
.attach_printable("failed to parse a uuid into a string")?
927-
.to_string();
924+
let string = parse_str(buffer)?;
928925
let str = string.trim_matches(|c: char| !c.is_ascii_alphanumeric());
929926
let str = match str.starts_with('{') {
930927
true => &str[1..str.len() - 1],

0 commit comments

Comments
 (0)