From 8b077f0c4167144064f838850a9cc84ff75cbae8 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Sat, 5 Apr 2025 00:20:06 +0200 Subject: [PATCH] gpui: Avoid dereferencing null pointer in `MacWindow::update_ime_position` (#28110) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems to be very similar to https://github.com/zed-industries/zed/pull/28059 Edit: Updated the reproduction-steps as I missed something. The method without a check currently causes my debug-builds to crash on the regular if I: - Run a debug build and open it fullscreen in a dedicated space on my Mac. - Work on any of the built-in languages (e.g. remove some content from any `highlights.scm`) - Reopen the workspace with the debug-build. - Crash. ~~We might actually be able to revert the changes made in https://github.com/zed-industries/zed/pull/21510 and just add the null-check. Then again, I am not at all sure whether that would work.­~~ See comment below. Release Notes: - N/A --- crates/gpui/src/platform/mac/window.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 97f8e9f422b11e84f8e25617edfa25cdca9ddab5..5c04c9505daf41994fa32b26e0c757284341d9f9 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -1161,6 +1161,9 @@ impl PlatformWindow for MacWindow { unsafe { let input_context: id = msg_send![class!(NSTextInputContext), currentInputContext]; + if input_context.is_null() { + return; + } let _: () = msg_send![input_context, invalidateCharacterCoordinates]; } })