Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Avoid dereferencing null pointer (#30579)
CharlesChen0823b2fc4064c0bf
diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rsindex 26a62aeadfd..c49219bff18 100644--- a/crates/gpui/src/platform/mac/window.rs+++ b/crates/gpui/src/platform/mac/window.rs@@ -844,6 +844,9 @@ impl PlatformWindow for MacWindow {fn display(&self) -> Option<Rc<dyn PlatformDisplay>> {unsafe {let screen = self.0.lock().native_window.screen();+ if screen.is_null() {+ return None;+ }let device_description: id = msg_send![screen, deviceDescription];let screen_number: id = NSDictionary::valueForKey_(device_description,@@ -1193,6 +1196,9 @@ impl rwh::HasDisplayHandle for MacWindow {fn get_scale_factor(native_window: id) -> f32 {let factor = unsafe {let screen: id = msg_send![native_window, screen];+ if screen.is_null() {+ return 1.0;+ }NSScreen::backingScaleFactor(screen) as f32};