Skip to content

Commit

Permalink
Merge pull request #9 from helmerapp/fix/segfault-while-extracting-ns…
Browse files Browse the repository at this point in the history
…string

fix: prevent segfaults while extracting NSString
  • Loading branch information
Pranav2612000 authored Jan 28, 2025
2 parents 8777b36 + ba61d3e commit c76a959
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/platform/macos/objc_wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,12 @@ impl NSString {

pub(crate) fn from_id_unretained(id: *mut AnyObject) -> Self {
unsafe {
let _: *mut AnyObject = msg_send![id, retain];
Self(id)
if (id as *const AnyObject).is_null() {
Self::new("")
} else {
let _: *mut AnyObject = msg_send![id, retain];
Self(id)
}
}
}

Expand Down

0 comments on commit c76a959

Please sign in to comment.