Fix memory leaks and crashes

This commit is contained in:
Twinaphex 2017-09-29 21:19:07 +02:00
parent 01099d526c
commit 66de49c987
3 changed files with 18 additions and 10 deletions

View File

@ -626,7 +626,8 @@ static void menu_action_setting_disp_set_label_menu_more(
{
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MORE), len);
*w = 19;
strlcpy(s2, path, len2);
if (path && !string_is_empty(path))
strlcpy(s2, path, len2);
}
static void menu_action_setting_disp_set_label_db_entry(
@ -640,7 +641,8 @@ static void menu_action_setting_disp_set_label_db_entry(
{
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MORE), len);
*w = 10;
strlcpy(s2, path, len2);
if (path && !string_is_empty(path))
strlcpy(s2, path, len2);
}
static void menu_action_setting_disp_set_label_entry(

View File

@ -2331,7 +2331,10 @@ static int xmb_draw_item(
}
else
{
enum msg_file_type type = msg_hash_to_file_type(msg_hash_calculate(entry->value));
enum msg_file_type type = FILE_TYPE_NONE;
if (entry->value && !string_is_empty(entry->value))
type = msg_hash_to_file_type(msg_hash_calculate(entry->value));
switch (type)
{
@ -2409,10 +2412,13 @@ static int xmb_draw_item(
ticker.s = tmp;
ticker.len = 35;
ticker.idx = frame_count / 20;
ticker.str = entry->value;
ticker.selected = (i == current);
menu_animation_ticker(&ticker);
if (entry->value && !string_is_empty(entry->value))
{
ticker.str = entry->value;
menu_animation_ticker(&ticker);
}
if (do_draw_text)
xmb_draw_text(menu_disp_info, xmb, tmp,

View File

@ -264,7 +264,7 @@ void menu_entry_reset(uint32_t i)
void menu_entry_get_value(menu_entry_t *entry, char *s, size_t len)
{
if (!entry)
if (!entry || !entry->value || string_is_empty(entry->value))
return;
strlcpy(s, entry->value, len);
}
@ -333,11 +333,11 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
cbs->action_get_value(list,
&entry->spacing, entry->type, (unsigned)i, label,
entry->value,
255 * sizeof(char),
entry_label, path,
tmp,
sizeof(tmp)
sizeof(tmp),
entry_label, path,
newpath,
sizeof(newpath)
);
if (!string_is_empty(tmp))