diff options
author | wm4 <wm4@nowhere> | 2014-02-26 20:32:14 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-02-26 21:03:35 +0100 |
commit | 8461143ed7c0088fe08379898e74a7fbcf0a9d1e (patch) | |
tree | 43816d6e3b6165a640a862c282dc480c2b0f7bca /options | |
parent | c176f2be39c26509fa1588ba1365427eff43b06f (diff) | |
download | mpv-8461143ed7c0088fe08379898e74a7fbcf0a9d1e.tar.bz2 mpv-8461143ed7c0088fe08379898e74a7fbcf0a9d1e.tar.xz |
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.
Diffstat (limited to 'options')
-rw-r--r-- | options/m_option.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/options/m_option.c b/options/m_option.c index 3c6a1fc946..9f7d250967 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -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) { - 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) @@ -1279,7 +1279,7 @@ static char *print_str_list(const m_option_t *opt, const void *src) char *ret = NULL; if (!(src && VAL(src))) - return NULL; + return talloc_strdup(NULL, ""); lst = VAL(src); for (int i = 0; lst[i]; i++) { |