Squash some more potential null pointer dereferences

This commit is contained in:
Lioncash 2014-09-11 22:59:52 -04:00
parent 59546e6f34
commit 64272ef327
5 changed files with 44 additions and 9 deletions

View File

@ -360,10 +360,15 @@ returntype main_entry(signature())
rarch_main_clear_state(); rarch_main_clear_state();
if (!(ret = (main_load_content(argc, argv, args, if (driver.frontend_ctx)
driver.frontend_ctx->environment_get, {
driver.frontend_ctx->process_args)))) if (!(ret = (main_load_content(argc, argv, args,
return_var(ret); driver.frontend_ctx->environment_get,
driver.frontend_ctx->process_args))))
{
return_var(ret);
}
}
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
#if defined(RARCH_CONSOLE) || defined(RARCH_MOBILE) #if defined(RARCH_CONSOLE) || defined(RARCH_MOBILE)

View File

@ -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) ? const char *shader_path = (g_settings.video.shader_enable && *g_settings.video.shader_path) ?
g_settings.video.shader_path : NULL; g_settings.video.shader_path : NULL;
enum rarch_shader_type type = gfx_shader_parse_type(shader_path, enum rarch_shader_type type;
gl->core_context ? RARCH_SHADER_GLSL : DEFAULT_SHADER_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; ret = 0;

View File

@ -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) static void parse_hat(struct retro_keybind *bind, const char *str)
{ {
if (!bind || !str)
return;
if (!isdigit(*str)) if (!isdigit(*str))
return; return;

View File

@ -16,8 +16,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stddef.h> #include <stddef.h>
#include "message_queue.h"
#include "boolean.h" #include "boolean.h"
#include "message_queue.h"
#include "retroarch_logger.h"
#include "compat/posix_string.h" #include "compat/posix_string.h"
struct queue_elem 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*) struct queue_elem *new_elem = (struct queue_elem*)
calloc(1, sizeof(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->prio = prio;
new_elem->duration = duration; new_elem->duration = duration;

View File

@ -752,17 +752,28 @@ static bool get_info_spectate(netplay_t *handle)
return ret; return ret;
} }
static void init_buffers(netplay_t *handle) static bool init_buffers(netplay_t *handle)
{ {
unsigned i; unsigned i;
handle->buffer = (struct delta_frame*)calloc(handle->buffer_size, handle->buffer = (struct delta_frame*)calloc(handle->buffer_size,
sizeof(*handle->buffer)); sizeof(*handle->buffer));
if (!handle->buffer)
return false;
handle->state_size = pretro_serialize_size(); handle->state_size = pretro_serialize_size();
for (i = 0; i < handle->buffer_size; i++) for (i = 0; i < handle->buffer_size; i++)
{ {
handle->buffer[i].state = malloc(handle->state_size); handle->buffer[i].state = malloc(handle->state_size);
if (!handle->buffer[i].state)
return false;
handle->buffer[i].is_simulated = true; handle->buffer[i].is_simulated = true;
} }
return true;
} }
netplay_t *netplay_new(const char *server, uint16_t port, 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; handle->buffer_size = frames + 1;
init_buffers(handle); if (!init_buffers(handle))
goto error;
handle->has_connection = true; handle->has_connection = true;
} }