fix some null pointer accesses with empty strings

This commit is contained in:
Brad Parker 2017-10-15 00:39:55 -04:00
parent f1d72e241c
commit 338723bc31
3 changed files with 14 additions and 3 deletions

View File

@ -154,6 +154,9 @@ size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
const uint8_t *sb = (const uint8_t*)s;
const uint8_t *sb_org = sb;
if (!s)
return 0;
while (*sb && chars-- > 0)
{
sb++;
@ -189,6 +192,10 @@ const char *utf8skip(const char *str, size_t chars)
size_t utf8len(const char *string)
{
size_t ret = 0;
if (!string)
return 0;
while (*string)
{
if ((*string & 0xC0) != 0x80)

View File

@ -2392,7 +2392,8 @@ static int xmb_draw_item(
ticker_limit = 70;
}
ticker_str = menu_entry_get_rich_label(entry);
if (!string_is_empty(entry->path))
ticker_str = menu_entry_get_rich_label(entry);
ticker.s = tmp;
ticker.len = ticker_limit;
@ -2400,7 +2401,8 @@ static int xmb_draw_item(
ticker.str = ticker_str;
ticker.selected = (i == current);
menu_animation_ticker(&ticker);
if (ticker.str)
menu_animation_ticker(&ticker);
label_offset = xmb->margins_label_top;
if (i == current && width > 320 && height > 240

View File

@ -123,7 +123,9 @@ char *menu_entry_get_rich_label(menu_entry_t *entry)
return NULL;
if (!string_is_empty(entry->rich_label))
return strdup(entry->rich_label);
return strdup(entry->path);
if (!string_is_empty(entry->path))
return strdup(entry->path);
return NULL;
}
char *menu_entry_get_sublabel(menu_entry_t *entry)