From ce112e0789b337490d686c80e76fc37f2a4bfe35 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 31 Jul 2011 20:25:22 +0300 Subject: [PATCH] options: fix failure to parse trailing ',' in string list A trailing separator in string list options was ignored after recent commit e873d703e9 ("options: change option parsing to use bstr"), which broke uses such as "-vo vdpau,". Fix. --- bstr.c | 3 +-- m_option.c | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bstr.c b/bstr.c index a2a49cc371..219c136d7c 100644 --- a/bstr.c +++ b/bstr.c @@ -129,8 +129,7 @@ struct bstr bstr_splice(struct bstr str, int start, int end) end += str.len; end = FFMIN(end, str.len); start = FFMAX(start, 0); - if (start >= end) - return (struct bstr){NULL, 0}; + end = FFMAX(end, start); str.start += start; str.len = end - start; return str; diff --git a/m_option.c b/m_option.c index 34b7cd7a99..a7321cb629 100644 --- a/m_option.c +++ b/m_option.c @@ -717,11 +717,13 @@ static int parse_str_list(const m_option_t *opt, struct bstr name, char *ptr = str.start; n = 0; - while (str.len) { + while (1) { struct bstr el = get_nextsep(&str, separator, 1); res[n] = bstrdup0(NULL, el); - str = bstr_cut(str, 1); n++; + if (!str.len) + break; + str = bstr_cut(str, 1); } res[n] = NULL; talloc_free(ptr);