mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
m_option: don't make "unset" string and string list return NULL strings
This is a bit weird: m_option_string types (i.e. char*) can be NULL. But they're supposed to be treated just like empty strings. So don't make the m_option_type.print function return NULL for these values. Returning NULL would mean failure. This didn't matter much before, but was quite visible through the client API.
This commit is contained in:
parent
c176f2be39
commit
8461143ed7
@ -983,7 +983,7 @@ static int parse_str(struct mp_log *log, const m_option_t *opt,
|
|||||||
|
|
||||||
static char *print_str(const m_option_t *opt, const void *val)
|
static char *print_str(const m_option_t *opt, const void *val)
|
||||||
{
|
{
|
||||||
return talloc_strdup(NULL, val ? VAL(val) : NULL);
|
return talloc_strdup(NULL, VAL(val) ? VAL(val) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_str(const m_option_t *opt, void *dst, const void *src)
|
static void copy_str(const m_option_t *opt, void *dst, const void *src)
|
||||||
@ -1279,7 +1279,7 @@ static char *print_str_list(const m_option_t *opt, const void *src)
|
|||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
if (!(src && VAL(src)))
|
if (!(src && VAL(src)))
|
||||||
return NULL;
|
return talloc_strdup(NULL, "");
|
||||||
lst = VAL(src);
|
lst = VAL(src);
|
||||||
|
|
||||||
for (int i = 0; lst[i]; i++) {
|
for (int i = 0; lst[i]; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user