diff --git a/docs/changelog.md b/docs/changelog.md index 77d9e1149..e6dab7029 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -36,6 +36,8 @@ As features stabilize some brief notes about them will accumulate here. #4876 * macOS: wacky initial window size with external monitors or certain font sizes. #4966 #4250 +* macOS: dragging non-filename data over wezterm could cause it to crash. #4771 + #### Updated * Bundled conpty.dll and OpenConsole.exe to build 1.19.240130002.nupkg diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index 07eae2f45..898a20347 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -2957,8 +2957,16 @@ impl WindowView { let mut inner = this.inner.borrow_mut(); let pb: id = unsafe { msg_send![sender, draggingPasteboard] }; + if pb.is_null() { + return NO; + } + let filenames = unsafe { NSPasteboard::propertyListForType(pb, appkit::NSFilenamesPboardType) }; + if filenames.is_null() { + return NO; + } + let paths = unsafe { filenames.iter() } .map(|file| unsafe { let path = nsstring_to_str(file); @@ -2975,8 +2983,16 @@ impl WindowView { let mut inner = this.inner.borrow_mut(); let pb: id = unsafe { msg_send![sender, draggingPasteboard] }; + if pb.is_null() { + return NO; + } + let filenames = unsafe { NSPasteboard::propertyListForType(pb, appkit::NSFilenamesPboardType) }; + if filenames.is_null() { + return NO; + } + let paths = unsafe { filenames.iter() } .map(|file| unsafe { let path = nsstring_to_str(file);