From 88dbe4ee631763e2d476f191d44b2881f060c9e7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 7 Oct 2014 04:12:41 +0200 Subject: [PATCH] (Apple) Put safeguards around input_state/button_pressed functions --- driver.c | 4 ---- input/apple_input.c | 9 +++++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/driver.c b/driver.c index b7a8aad9d4..b88076d97c 100644 --- a/driver.c +++ b/driver.c @@ -28,10 +28,6 @@ #include "audio/audio_thread_wrapper.h" #include "gfx/gfx_common.h" -#ifdef HAVE_X11 -#include "gfx/context/x11_common.h" -#endif - #ifdef HAVE_MENU #include "frontend/menu/menu_common.h" #endif diff --git a/input/apple_input.c b/input/apple_input.c index d9af923d6a..a1b281e08b 100644 --- a/input/apple_input.c +++ b/input/apple_input.c @@ -463,6 +463,9 @@ static int16_t apple_input_state(void *data, { apple_input_data_t *apple = (apple_input_data_t*)data; + if (!apple || !apple->joypad) + return 0; + switch (device) { case RETRO_DEVICE_JOYPAD: @@ -489,8 +492,10 @@ static int16_t apple_input_state(void *data, static bool apple_input_bind_button_pressed(void *data, int key) { apple_input_data_t *apple = (apple_input_data_t*)data; - return apple_input_is_pressed(apple, 0, g_settings.input.binds[0], key) || - input_joypad_pressed(apple->joypad, 0, g_settings.input.binds[0], key); + if (apple && apple->joypad) + return apple_input_is_pressed(apple, 0, g_settings.input.binds[0], key) || + input_joypad_pressed(apple->joypad, 0, g_settings.input.binds[0], key); + return false; } static void apple_input_free(void *data)