Fix a few memory leaks

Also guard against calloc failure in lakka_init.
This commit is contained in:
Lioncash 2014-09-15 11:20:05 -04:00
parent a71b42e4b3
commit d1f908b8f8
2 changed files with 17 additions and 4 deletions

View File

@ -291,12 +291,15 @@ static bool parse_line(config_file_t *conf,
size_t cur_size = 8;
size_t index = 0;
if (!line || !*line)
return false;
if (!key)
return false;
if (!line || !*line)
{
free(key);
return false;
}
comment = strip_comment(line);
/* Starting line with # and include includes config files. */
@ -306,6 +309,7 @@ static bool parse_line(config_file_t *conf,
if (strstr(comment, "include ") == comment)
{
add_sub_conf(conf, comment + strlen("include "));
free(key);
return false;
}
}

View File

@ -1122,6 +1122,12 @@ static void *lakka_init(void)
categories = (menu_category_t*)
calloc(num_categories, sizeof(menu_category_t));
if (!categories)
{
free(menu);
return NULL;
}
lakka_init_settings();
for (i = 1; i < num_categories; i++)
@ -1137,7 +1143,10 @@ static void *lakka_init(void)
info = (core_info_t*)&info_list->list[i-1];
if (info == NULL)
return NULL;
{
free(menu);
return NULL
};
strlcpy(category->name, info->display_name, sizeof(category->name));
strlcpy(category->libretro, info->path, sizeof(category->libretro));