From 8461143ed7c0088fe08379898e74a7fbcf0a9d1e Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 26 Feb 2014 20:32:14 +0100 Subject: 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. --- options/m_option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'options/m_option.c') 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++) { -- cgit v1.2.3