diff mbox

[FFmpeg-devel] opt: reject denominator zero as out of range

Message ID 907a7206-4b4f-171d-39c3-03a5e19964ac@googlemail.com
State Accepted
Commit 3ab8436ff611aa488226bbcb25c84bb687b2bf46
Headers show

Commit Message

Andreas Cadhalpun Dec. 12, 2016, 12:31 a.m. UTC
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavutil/opt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Dec. 12, 2016, 2:39 a.m. UTC | #1
On Mon, Dec 12, 2016 at 01:31:47AM +0100, Andreas Cadhalpun wrote:
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> ---
>  libavutil/opt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index f855ccb..6ae2af6 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -97,7 +97,7 @@ static int read_number(const AVOption *o, const void *dst, double *num, int *den
>  static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum)
>  {
>      if (o->type != AV_OPT_TYPE_FLAGS &&
> -        (o->max * den < num * intnum || o->min * den > num * intnum)) {
> +        (!den || o->max * den < num * intnum || o->min * den > num * intnum)) {

probably ok
(i assume we dont want/need to have 1/0 and max=infinity )

[...]
Andreas Cadhalpun Dec. 12, 2016, 11:02 p.m. UTC | #2
On 12.12.2016 03:39, Michael Niedermayer wrote:
> On Mon, Dec 12, 2016 at 01:31:47AM +0100, Andreas Cadhalpun wrote:
>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
>> ---
>>  libavutil/opt.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavutil/opt.c b/libavutil/opt.c
>> index f855ccb..6ae2af6 100644
>> --- a/libavutil/opt.c
>> +++ b/libavutil/opt.c
>> @@ -97,7 +97,7 @@ static int read_number(const AVOption *o, const void *dst, double *num, int *den
>>  static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum)
>>  {
>>      if (o->type != AV_OPT_TYPE_FLAGS &&
>> -        (o->max * den < num * intnum || o->min * den > num * intnum)) {
>> +        (!den || o->max * den < num * intnum || o->min * den > num * intnum)) {
> 
> probably ok

Pushed.

> (i assume we dont want/need to have 1/0 and max=infinity )

I also think so.

Best regards,
Andreas
diff mbox

Patch

diff --git a/libavutil/opt.c b/libavutil/opt.c
index f855ccb..6ae2af6 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -97,7 +97,7 @@  static int read_number(const AVOption *o, const void *dst, double *num, int *den
 static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum)
 {
     if (o->type != AV_OPT_TYPE_FLAGS &&
-        (o->max * den < num * intnum || o->min * den > num * intnum)) {
+        (!den || 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, o->name, o->min, o->max);