Fix some more possible null pointer dereferences

This commit is contained in:
Lioncash 2014-09-12 00:30:53 -04:00
parent f5e523a8c3
commit be12253243
3 changed files with 18 additions and 3 deletions

View File

@ -145,10 +145,17 @@ static void blit_line(int x, int y, const char *message, bool green)
}
}
static void init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf)
static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf)
{
unsigned i;
uint8_t *font = (uint8_t *) calloc(1, FONT_OFFSET(256));
if (!font)
{
RARCH_ERR("Font memory allocation failed in %s", __FUNCTION__);
return false;
}
menu->alloc_font = true;
for (i = 0; i < 256; i++)
{
@ -159,6 +166,7 @@ static void init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf)
}
menu->font = font;
return true;
}
static bool rguidisp_init_font(void *data)
@ -169,7 +177,7 @@ static bool rguidisp_init_font(void *data)
const uint8_t *font_bin_buf = bitmap_bin;
if (font_bmp_buf)
init_font(menu, font_bmp_buf);
return init_font(menu, font_bmp_buf);
else if (font_bin_buf)
menu->font = font_bin_buf;
else

View File

@ -434,6 +434,10 @@ static bool d3d_construct(d3d_video_t *d3d,
free(d3d->menu);
d3d->menu = (overlay_t*)calloc(1, sizeof(overlay_t));
if (!d3d->menu)
return false;
d3d->menu->tex_coords.x = 0;
d3d->menu->tex_coords.y = 0;
d3d->menu->tex_coords.w = 1;
@ -630,7 +634,7 @@ static void *d3d_init(const video_info_t *info,
vid->ctx_driver = d3d_get_context(vid);
if (!vid->ctx_driver)
{
free(vid);
delete vid;
return NULL;
}

View File

@ -40,6 +40,9 @@ static inline bool validate_param_name(const char *name)
"PASS",
};
if (!name)
return false;
for (unsigned i = 0; i < sizeof(illegal) / sizeof(illegal[0]); i++)
if (strstr(name, illegal[i]) == name)
return false;