Merge pull request #983 from lioncash/derefs
Fix some more possible null pointer dereferences
This commit is contained in:
commit
0e2282185f
|
@ -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;
|
unsigned i;
|
||||||
uint8_t *font = (uint8_t *) calloc(1, FONT_OFFSET(256));
|
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;
|
menu->alloc_font = true;
|
||||||
for (i = 0; i < 256; i++)
|
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;
|
menu->font = font;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool rguidisp_init_font(void *data)
|
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;
|
const uint8_t *font_bin_buf = bitmap_bin;
|
||||||
|
|
||||||
if (font_bmp_buf)
|
if (font_bmp_buf)
|
||||||
init_font(menu, font_bmp_buf);
|
return init_font(menu, font_bmp_buf);
|
||||||
else if (font_bin_buf)
|
else if (font_bin_buf)
|
||||||
menu->font = font_bin_buf;
|
menu->font = font_bin_buf;
|
||||||
else
|
else
|
||||||
|
|
|
@ -434,6 +434,10 @@ static bool d3d_construct(d3d_video_t *d3d,
|
||||||
free(d3d->menu);
|
free(d3d->menu);
|
||||||
|
|
||||||
d3d->menu = (overlay_t*)calloc(1, sizeof(overlay_t));
|
d3d->menu = (overlay_t*)calloc(1, sizeof(overlay_t));
|
||||||
|
|
||||||
|
if (!d3d->menu)
|
||||||
|
return false;
|
||||||
|
|
||||||
d3d->menu->tex_coords.x = 0;
|
d3d->menu->tex_coords.x = 0;
|
||||||
d3d->menu->tex_coords.y = 0;
|
d3d->menu->tex_coords.y = 0;
|
||||||
d3d->menu->tex_coords.w = 1;
|
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);
|
vid->ctx_driver = d3d_get_context(vid);
|
||||||
if (!vid->ctx_driver)
|
if (!vid->ctx_driver)
|
||||||
{
|
{
|
||||||
free(vid);
|
delete vid;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@ static inline bool validate_param_name(const char *name)
|
||||||
"PASS",
|
"PASS",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!name)
|
||||||
|
return false;
|
||||||
|
|
||||||
for (unsigned i = 0; i < sizeof(illegal) / sizeof(illegal[0]); i++)
|
for (unsigned i = 0; i < sizeof(illegal) / sizeof(illegal[0]); i++)
|
||||||
if (strstr(name, illegal[i]) == name)
|
if (strstr(name, illegal[i]) == name)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue