Message ID | 20180930204513.26772-3-cus@passwd.hu |
---|---|
State | Accepted |
Commit | d40dc64173a140755f36492a0c20fc41b27d66c3 |
Headers | show |
On 9/30/18, Marton Balint <cus@passwd.hu> wrote: > Signed-off-by: Marton Balint <cus@passwd.hu> > --- > libavutil/opt.c | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > diff --git a/libavutil/opt.c b/libavutil/opt.c > index 99282605f5..93d6c26c11 100644 > --- a/libavutil/opt.c > +++ b/libavutil/opt.c > @@ -496,15 +496,22 @@ int av_opt_set(void *obj, const char *name, const char > *val, int search_flags) > case AV_OPT_TYPE_SAMPLE_FMT: > return set_string_sample_fmt(obj, o, val, dst); > case AV_OPT_TYPE_DURATION: > - if (!val) { > - *(int64_t *)dst = 0; > + { > + int64_t usecs = 0; > + if (val) { > + if ((ret = av_parse_time(&usecs, val, 1)) < 0) { > + av_log(obj, AV_LOG_ERROR, "Unable to parse option value > \"%s\" as duration\n", val); > + return ret; > + } > + } > + if (usecs < o->min || usecs > o->max) { > + av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out > of range [%g - %g]\n", > + usecs / 1000000.0, o->name, o->min / 1000000.0, > o->max / 1000000.0); > + return AVERROR(ERANGE); > + } > + *(int64_t *)dst = usecs; > return 0; > - } else { > - if ((ret = av_parse_time(dst, val, 1)) < 0) > - av_log(obj, AV_LOG_ERROR, "Unable to parse option value > \"%s\" as duration\n", val); > - return ret; > } > - break; > case AV_OPT_TYPE_COLOR: > return set_string_color(obj, o, val, dst); > case AV_OPT_TYPE_CHANNEL_LAYOUT: > -- > 2.16.4 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > LGTM
diff --git a/libavutil/opt.c b/libavutil/opt.c index 99282605f5..93d6c26c11 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -496,15 +496,22 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) case AV_OPT_TYPE_SAMPLE_FMT: return set_string_sample_fmt(obj, o, val, dst); case AV_OPT_TYPE_DURATION: - if (!val) { - *(int64_t *)dst = 0; + { + int64_t usecs = 0; + if (val) { + if ((ret = av_parse_time(&usecs, val, 1)) < 0) { + av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val); + return ret; + } + } + if (usecs < o->min || usecs > o->max) { + av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range [%g - %g]\n", + usecs / 1000000.0, o->name, o->min / 1000000.0, o->max / 1000000.0); + return AVERROR(ERANGE); + } + *(int64_t *)dst = usecs; return 0; - } else { - if ((ret = av_parse_time(dst, val, 1)) < 0) - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val); - return ret; } - break; case AV_OPT_TYPE_COLOR: return set_string_color(obj, o, val, dst); case AV_OPT_TYPE_CHANNEL_LAYOUT:
Signed-off-by: Marton Balint <cus@passwd.hu> --- libavutil/opt.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)