mirror of https://github.com/mpv-player/mpv
options: reject nan, inf, 0:0, etc. for float options
Same for time values.
This commit is contained in:
parent
bbea6cc6d4
commit
7af2bc6607
|
@ -522,6 +522,10 @@ static int clamp_double(const m_option_t *opt, void *val)
|
||||||
v = opt->min;
|
v = opt->min;
|
||||||
r = M_OPT_OUT_OF_RANGE;
|
r = M_OPT_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
if (!isfinite(v)) {
|
||||||
|
v = opt->min;
|
||||||
|
r = M_OPT_OUT_OF_RANGE;
|
||||||
|
}
|
||||||
VAL(val) = v;
|
VAL(val) = v;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -562,6 +566,13 @@ static int parse_double(const m_option_t *opt, struct bstr name,
|
||||||
return M_OPT_OUT_OF_RANGE;
|
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)
|
if (dst)
|
||||||
VAL(dst) = tmp_float;
|
VAL(dst) = tmp_float;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1532,6 +1543,8 @@ static int parse_timestring(struct bstr str, double *time, char endchar)
|
||||||
return 0; /* unsupported time format */
|
return 0; /* unsupported time format */
|
||||||
if (len < str.len && str.start[len] != endchar)
|
if (len < str.len && str.start[len] != endchar)
|
||||||
return 0; /* invalid extra characters at the end */
|
return 0; /* invalid extra characters at the end */
|
||||||
|
if (!isfinite(*time))
|
||||||
|
return 0;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue