Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67809f4

Browse files
authored
fix(macos): crash when custom protocol response is empty (#567)
1 parent a5ddb5c commit 67809f4

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wry": patch
3+
---
4+
5+
Fixes a crash when the custom protocol response is empty on macOS.

src/webview/wkwebview/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub use web_context::WebContextImpl;
1111
#[cfg(target_os = "macos")]
1212
use cocoa::appkit::{NSView, NSViewHeightSizable, NSViewWidthSizable};
1313
use cocoa::{
14-
base::{id, nil, YES},
14+
base::{id, nil, NO, YES},
1515
foundation::{NSDictionary, NSFastEnumeration, NSInteger},
1616
};
1717

@@ -183,8 +183,7 @@ impl InnerWebView {
183183
// Send data
184184
let bytes = content.as_ptr() as *mut c_void;
185185
let data: id = msg_send![class!(NSData), alloc];
186-
let data: id =
187-
msg_send![data, initWithBytesNoCopy:bytes length:content.len() freeWhenDone: YES];
186+
let data: id = msg_send![data, initWithBytesNoCopy:bytes length:content.len() freeWhenDone: if content.len() == 0 { NO } else { YES }];
188187
let () = msg_send![task, didReceiveData: data];
189188
} else {
190189
let urlresponse: id = msg_send![class!(NSHTTPURLResponse), alloc];

0 commit comments

Comments
 (0)