[libav-stable] [libav-commits] mathematics: remove asserts from av_rescale_rnd()

Reinhard Tartler siretart at gmail.com
Sat Feb 1 20:50:24 CET 2014


I would like to include the following patch in the next stable point
releases, as they fix very subtle problems such as:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718805

Any objections?

On Fri, Jan 3, 2014 at 11:04 AM, Anton Khirnov <git at libav.org> wrote:
> Module: libav
> Branch: master
> Commit: 94a417acc05cc5151b473abc0bf51fad26f8c5a0
>
> Author:    Anton Khirnov <anton at khirnov.net>
> Committer: Anton Khirnov <anton at khirnov.net>
> Date:      Thu Dec 12 07:34:13 2013 +0100
>
> mathematics: remove asserts from av_rescale_rnd()
>
> It is a public function, it must not assert on its parameters.
>
> ---
>
>  libavutil/mathematics.c |    7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
> index 137683e..1a38f64 100644
> --- a/libavutil/mathematics.c
> +++ b/libavutil/mathematics.c
> @@ -23,7 +23,6 @@
>   * miscellaneous math routines and tables
>   */
>
> -#include <assert.h>
>  #include <stdint.h>
>  #include <limits.h>
>
> @@ -58,9 +57,9 @@ int64_t av_gcd(int64_t a, int64_t b){
>
>  int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
>      int64_t r=0;
> -    assert(c > 0);
> -    assert(b >=0);
> -    assert((unsigned)rnd<=5 && rnd!=4);
> +
> +    if (c <= 0 || b < 0 || rnd == 4 || rnd > 5)
> +        return INT64_MIN;
>
>      if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1));
>
>
> _______________________________________________
> libav-commits mailing list
> libav-commits at libav.org
> https://lists.libav.org/mailman/listinfo/libav-commits



-- 
regards,
    Reinhard


More information about the libav-stable mailing list