diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-02-23 08:20:02 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-02-23 08:20:02 +0200 |
commit | d2e0544e0aedbaec64b7d97cd17c41c281741b1e (patch) | |
tree | 73036f53e708ab64921c81ed1b9b2d228f9789e9 | |
parent | f15ced3f188b2dfa3f2b9f1b1cda56774977b24f (diff) | |
download | redot-engine-d2e0544e0aedbaec64b7d97cd17c41c281741b1e.tar.gz |
[macOS] Add null checks for `NSString stringWithUTF8String`.
-rw-r--r-- | platform/macos/dir_access_macos.mm | 7 | ||||
-rw-r--r-- | platform/macos/godot_application_delegate.mm | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/platform/macos/dir_access_macos.mm b/platform/macos/dir_access_macos.mm index 66d81f2687..37f717c9de 100644 --- a/platform/macos/dir_access_macos.mm +++ b/platform/macos/dir_access_macos.mm @@ -41,9 +41,10 @@ String DirAccessMacOS::fix_unicode_name(const char *p_name) const { String fname; - NSString *nsstr = [[NSString stringWithUTF8String:p_name] precomposedStringWithCanonicalMapping]; - - fname.parse_utf8([nsstr UTF8String]); + if (p_name != nullptr) { + NSString *nsstr = [[NSString stringWithUTF8String:p_name] precomposedStringWithCanonicalMapping]; + fname.parse_utf8([nsstr UTF8String]); + } return fname; } diff --git a/platform/macos/godot_application_delegate.mm b/platform/macos/godot_application_delegate.mm index 2e76d4aa97..b3759e66f5 100644 --- a/platform/macos/godot_application_delegate.mm +++ b/platform/macos/godot_application_delegate.mm @@ -125,7 +125,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notice { NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; - NSString *nsbundleid_env = [NSString stringWithUTF8String:getenv("__CFBundleIdentifier")]; + const char *bundled_id = getenv("__CFBundleIdentifier"); + NSString *nsbundleid_env = [NSString stringWithUTF8String:(bundled_id != nullptr) ? bundled_id : ""]; NSString *nsbundleid = [[NSBundle mainBundle] bundleIdentifier]; if (nsappname == nil || isatty(STDOUT_FILENO) || isatty(STDIN_FILENO) || isatty(STDERR_FILENO) || ![nsbundleid isEqualToString:nsbundleid_env]) { // If the executable is started from terminal or is not bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored). |