Make sanitize_to_string safer

This commit is contained in:
twinaphex 2017-09-29 05:26:48 +02:00
parent 15bb8e2ebe
commit 642818d59c

View File

@ -41,9 +41,13 @@ static void sanitize_to_string(char *s, const char *label, size_t len)
new_label[0] = '\0';
strlcpy(new_label, label, sizeof(new_label));
strlcpy(s, new_label, len);
replace_chars(s, '_', ' ');
if (label && !string_is_empty(label))
strlcpy(new_label, label, sizeof(new_label));
if (s && !string_is_empty(new_label))
{
strlcpy(s, new_label, len);
replace_chars(s, '_', ' ');
}
}
static int fill_title(char *s, const char *title, const char *path, size_t len)