diff --git a/.changes/fix-macos-ipc-empty-body-crash.md b/.changes/fix-macos-ipc-empty-body-crash.md new file mode 100644 index 000000000..268dbecd7 --- /dev/null +++ b/.changes/fix-macos-ipc-empty-body-crash.md @@ -0,0 +1,5 @@ +--- +"wry": patch +--- + +On macOS, fixed a crash when sending empty body by IPC. diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index a1ffb68f4..3b1b2312d 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -232,7 +232,9 @@ impl InnerWebView { if !body.is_null() { let length = msg_send![body, length]; let data_bytes: id = msg_send![body, bytes]; - sent_form_body = slice::from_raw_parts(data_bytes as *const u8, length).to_vec(); + if !data_bytes.is_null() { + sent_form_body = slice::from_raw_parts(data_bytes as *const u8, length).to_vec(); + } } else if !body_stream.is_null() { let _: () = msg_send![body_stream, open];