Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix unsafe precondition violation when building with nightly `rustc` (#8691)

Liam Murphy090306293308
diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rs
index 473fb5978a2..8b35114b7f5 100644
--- a/crates/gpui/src/platform/mac/platform.rs
+++ b/crates/gpui/src/platform/mac/platform.rs
@@ -5,7 +5,7 @@ use crate::{
MenuItem, PathPromptOptions, Platform, PlatformDisplay, PlatformInput, PlatformTextSystem,
PlatformWindow, Result, SemanticVersion, Task, WindowAppearance, WindowOptions,
};
-use anyhow::anyhow;
+use anyhow::{anyhow, bail};
use block::ConcreteBlock;
use cocoa::{
appkit::{
@@ -685,6 +685,9 @@ impl Platform for MacPlatform {
Err(anyhow!("app is not running inside a bundle"))
} else {
let version: id = msg_send![bundle, objectForInfoDictionaryKey: ns_string("CFBundleShortVersionString")];
+ if version.is_null() {
+ bail!("bundle does not have version");
+ }
let len = msg_send![version, lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
let bytes = version.UTF8String() as *const u8;
let version = str::from_utf8(slice::from_raw_parts(bytes, len)).unwrap();