Skip to content

Commit

Permalink
fix: remove trailing null terminator from NSString (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
knopp authored Oct 7, 2023
1 parent 5c045a8 commit 3224ea1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions super_native_extensions/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion super_native_extensions/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rand = "0.8.5"
url = "2.2.2"
irondash_engine_context = "0.3.0"
irondash_run_loop = "0.3.0"
irondash_message_channel = { version = "0.3.0", features = ["derive"] }
irondash_message_channel = { version = "0.3.1", features = ["derive"] }

[build-dependencies]
serde = { version = "1.0.119", features = ["derive"] }
Expand Down
5 changes: 4 additions & 1 deletion super_native_extensions/rust/src/darwin/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ pub unsafe fn from_nsstring(ns_string: id) -> String {

let len = ns_string.len();

let bytes = slice::from_raw_parts(bytes, len);
let mut bytes = slice::from_raw_parts(bytes, len);
while bytes.last() == Some(&0) {
bytes = &bytes[..bytes.len() - 1];
}
std::str::from_utf8(bytes).unwrap().into()
}

Expand Down

0 comments on commit 3224ea1

Please sign in to comment.