diff --git a/frontend/frontend.c b/frontend/frontend.c index 53ad427254..56e813f833 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -360,10 +360,15 @@ returntype main_entry(signature()) rarch_main_clear_state(); - if (!(ret = (main_load_content(argc, argv, args, - driver.frontend_ctx->environment_get, - driver.frontend_ctx->process_args)))) - return_var(ret); + if (driver.frontend_ctx) + { + if (!(ret = (main_load_content(argc, argv, args, + driver.frontend_ctx->environment_get, + driver.frontend_ctx->process_args)))) + { + return_var(ret); + } + } #if defined(HAVE_MENU) #if defined(RARCH_CONSOLE) || defined(RARCH_MOBILE) diff --git a/gfx/gl.c b/gfx/gl.c index 327f29cf62..0d627252a7 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -203,8 +203,16 @@ static bool gl_shader_init(gl_t *gl) const char *shader_path = (g_settings.video.shader_enable && *g_settings.video.shader_path) ? g_settings.video.shader_path : NULL; - enum rarch_shader_type type = gfx_shader_parse_type(shader_path, - gl->core_context ? RARCH_SHADER_GLSL : DEFAULT_SHADER_TYPE); + enum rarch_shader_type type; + + if (!gl) + { + RARCH_ERR("Invalid GL instance passed to %s", __FUNCTION__); + return false; + } + + type = gfx_shader_parse_type(shader_path, + gl->core_context ? RARCH_SHADER_GLSL : DEFAULT_SHADER_TYPE); ret = 0; diff --git a/input/input_common.c b/input/input_common.c index b1f8021662..897e7f403d 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -1289,6 +1289,9 @@ unsigned input_translate_str_to_bind_id(const char *str) static void parse_hat(struct retro_keybind *bind, const char *str) { + if (!bind || !str) + return; + if (!isdigit(*str)) return; diff --git a/message_queue.c b/message_queue.c index 67d5c77223..343e6dd8cd 100644 --- a/message_queue.c +++ b/message_queue.c @@ -16,8 +16,9 @@ #include #include #include -#include "message_queue.h" #include "boolean.h" +#include "message_queue.h" +#include "retroarch_logger.h" #include "compat/posix_string.h" struct queue_elem @@ -72,6 +73,11 @@ void msg_queue_push(msg_queue_t *queue, const char *msg, struct queue_elem *new_elem = (struct queue_elem*) calloc(1, sizeof(struct queue_elem)); + if (!new_elem) + { + RARCH_ERR("New element allocation failed in %s", __FUNCTION__); + return; + } new_elem->prio = prio; new_elem->duration = duration; diff --git a/netplay.c b/netplay.c index 410475f236..248fca1a69 100644 --- a/netplay.c +++ b/netplay.c @@ -752,17 +752,28 @@ static bool get_info_spectate(netplay_t *handle) return ret; } -static void init_buffers(netplay_t *handle) +static bool init_buffers(netplay_t *handle) { unsigned i; handle->buffer = (struct delta_frame*)calloc(handle->buffer_size, sizeof(*handle->buffer)); + + if (!handle->buffer) + return false; + handle->state_size = pretro_serialize_size(); + for (i = 0; i < handle->buffer_size; i++) { handle->buffer[i].state = malloc(handle->state_size); + + if (!handle->buffer[i].state) + return false; + handle->buffer[i].is_simulated = true; } + + return true; } netplay_t *netplay_new(const char *server, uint16_t port, @@ -818,7 +829,9 @@ netplay_t *netplay_new(const char *server, uint16_t port, handle->buffer_size = frames + 1; - init_buffers(handle); + if (!init_buffers(handle)) + goto error; + handle->has_connection = true; }