diff options
author | wm4 <wm4@nowhere> | 2013-02-24 21:05:59 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-02-26 01:55:52 +0100 |
commit | 7af2bc66079a0d427946e10ec7869fa042a6ae8a (patch) | |
tree | a96ef9133d59156c7022aac8dbf29cfa810231b2 | |
parent | bbea6cc6d47123aafd88cd11ee5dccda6c776b89 (diff) | |
download | mpv-7af2bc66079a0d427946e10ec7869fa042a6ae8a.tar.bz2 mpv-7af2bc66079a0d427946e10ec7869fa042a6ae8a.tar.xz |
options: reject nan, inf, 0:0, etc. for float options
Same for time values.
-rw-r--r-- | core/m_option.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/m_option.c b/core/m_option.c index 883ecd70a0..507d6cc2c7 100644 --- a/core/m_option.c +++ b/core/m_option.c @@ -522,6 +522,10 @@ static int clamp_double(const m_option_t *opt, void *val) v = opt->min; r = M_OPT_OUT_OF_RANGE; } + if (!isfinite(v)) { + v = opt->min; + r = M_OPT_OUT_OF_RANGE; + } VAL(val) = v; return r; } @@ -562,6 +566,13 @@ static int parse_double(const m_option_t *opt, struct bstr name, return M_OPT_OUT_OF_RANGE; } + if (!isfinite(tmp_float)) { + mp_msg(MSGT_CFGPARSER, MSGL_ERR, + "The %.*s option must be a finite number: %.*s\n", + BSTR_P(name), BSTR_P(param)); + return M_OPT_OUT_OF_RANGE; + } + if (dst) VAL(dst) = tmp_float; return 1; @@ -1532,6 +1543,8 @@ static int parse_timestring(struct bstr str, double *time, char endchar) return 0; /* unsupported time format */ if (len < str.len && str.start[len] != endchar) return 0; /* invalid extra characters at the end */ + if (!isfinite(*time)) + return 0; return len; } |