avoptions: Don't divide by zero if requesting a nonexistent option in av_get_int

Message ID 1306088259-96657-1-git-send-email-martin@martin.st
State Rejected
Headers show

Commit Message

Martin Storsjö May 22, 2011, 6:17 p.m.
---
 libavutil/opt.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Justin Ruggles May 22, 2011, 6:29 p.m. | #1
On 05/22/2011 02:17 PM, Martin Storsjö wrote:

> ---
>  libavutil/opt.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index 57e3248..ada21e8 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -280,7 +280,8 @@ static int av_get_number(void *obj, const char *name, const AVOption **o_out, do
>                                                          return 0;
>      }
>  error:
> -    *den=*intnum=0;
> +    *intnum = 0;
> +    *den    = 1;
>      return -1;
>  }


why are they even modified in this case? shouldn't returning -1 be
enough?  it seems that the functions using this aren't even checking the
return value...  fixing that seems like a more appropriate solution.

-Justin

Patch

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 57e3248..ada21e8 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -280,7 +280,8 @@  static int av_get_number(void *obj, const char *name, const AVOption **o_out, do
                                                         return 0;
     }
 error:
-    *den=*intnum=0;
+    *intnum = 0;
+    *den    = 1;
     return -1;
 }