From 02eca41ea1d986028769ece378307c9d6181d195 Mon Sep 17 00:00:00 2001 From: neville Date: Sun, 29 Mar 2015 18:17:29 +0200 Subject: [PATCH] (OSX platform) Make code more robust --- apple/OSX/platform.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apple/OSX/platform.m b/apple/OSX/platform.m index 24cbec8592..7ba5a42ed6 100644 --- a/apple/OSX/platform.m +++ b/apple/OSX/platform.m @@ -268,8 +268,10 @@ static void poll_iteration(void) { global_t *global = global_get_ptr(); NSString *__core = [filenames objectAtIndex:0]; - const char *core_name = global->menu.info.library_name; - strlcpy(global->fullpath, __core.UTF8String, sizeof(global->fullpath)); + const char *core_name = global ? global->menu.info.library_name : NULL; + + if (global) + strlcpy(global->fullpath, __core.UTF8String, sizeof(global->fullpath)); if (core_name) rarch_main_command(RARCH_CMD_LOAD_CONTENT); @@ -298,8 +300,10 @@ static void poll_iteration(void) global_t *global = global_get_ptr(); NSURL *url = (NSURL*)panel.URL; NSString *__core = url.path; - const char *core_name = global->menu.info.library_name; - strlcpy(global->fullpath, __core.UTF8String, sizeof(global->fullpath)); + const char *core_name = global ? global->menu.info.library_name : NULL; + + if (global) + strlcpy(global->fullpath, __core.UTF8String, sizeof(global->fullpath)); if (core_name) rarch_main_command(RARCH_CMD_LOAD_CONTENT); @@ -328,7 +332,7 @@ static void poll_iteration(void) [[NSApplication sharedApplication] endSheet:self.coreSelectSheet returnCode:0]; [self.coreSelectSheet orderOut:self]; - if (global->system.shutdown) + if (global && global->system.shutdown) return; /* TODO - rewrite this. */ @@ -339,7 +343,7 @@ static void poll_iteration(void) self.core = objc_getAssociatedObject(cb.objectValueOfSelectedItem, associated_core_key); #endif - if (!global->main_is_init) + if (global && !global->main_is_init) { /* TODO/FIXME: Set core/content here. */ rarch_main_command(RARCH_CMD_LOAD_CORE);