From 52835cb8e16cd54bd4b3052279f184882cbf54c2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 3 May 2015 16:14:55 +0200 Subject: [PATCH] avutil/opt: Avoid division by 0 Signed-off-by: Michael Niedermayer --- libavutil/opt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 092446b02b..62db1b50b7 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -85,8 +85,9 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int { if (o->type != AV_OPT_TYPE_FLAGS && (o->max * den < num * intnum || o->min * den > num * intnum)) { + num = den ? num*intnum/den : (num*intnum ? INFINITY : NAN); av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range [%g - %g]\n", - num*intnum/den, o->name, o->min, o->max); + num, o->name, o->min, o->max); return AVERROR(ERANGE); } if (o->type == AV_OPT_TYPE_FLAGS) {