Fix unsafe precondition violation when building with nightly rustc
(#8691)
Fixes #8658 Release Notes: - N/A
This commit is contained in:
parent
e5e6c7f09d
commit
0903062933
1 changed files with 4 additions and 1 deletions
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
MenuItem, PathPromptOptions, Platform, PlatformDisplay, PlatformInput, PlatformTextSystem,
|
MenuItem, PathPromptOptions, Platform, PlatformDisplay, PlatformInput, PlatformTextSystem,
|
||||||
PlatformWindow, Result, SemanticVersion, Task, WindowAppearance, WindowOptions,
|
PlatformWindow, Result, SemanticVersion, Task, WindowAppearance, WindowOptions,
|
||||||
};
|
};
|
||||||
use anyhow::anyhow;
|
use anyhow::{anyhow, bail};
|
||||||
use block::ConcreteBlock;
|
use block::ConcreteBlock;
|
||||||
use cocoa::{
|
use cocoa::{
|
||||||
appkit::{
|
appkit::{
|
||||||
|
@ -685,6 +685,9 @@ impl Platform for MacPlatform {
|
||||||
Err(anyhow!("app is not running inside a bundle"))
|
Err(anyhow!("app is not running inside a bundle"))
|
||||||
} else {
|
} else {
|
||||||
let version: id = msg_send![bundle, objectForInfoDictionaryKey: ns_string("CFBundleShortVersionString")];
|
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 len = msg_send![version, lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
|
||||||
let bytes = version.UTF8String() as *const u8;
|
let bytes = version.UTF8String() as *const u8;
|
||||||
let version = str::from_utf8(slice::from_raw_parts(bytes, len)).unwrap();
|
let version = str::from_utf8(slice::from_raw_parts(bytes, len)).unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue