[FFmpeg-devel] Patch for FPE (floating point exception)

Michael Niedermayer michael at niedermayer.cc
Fri Jun 16 04:42:11 EEST 2017


On Tue, Jun 06, 2017 at 06:41:55PM +0200, Robert Nagtegaal wrote:
> Dear developers,
> 
> Most unfortunately I found 2 bugs in ffserver.c  Both are related to
> floating point bugs. I wrote a patch and submitted it on git:
> 
> https://github.com/masikh/FFmpeg/commit/50326ef568.patch

> commit 46f83db9da7397b1d390a98aecd8d812dee37d98 (HEAD -> master)
> Author: Robert Nagtegaal <masikh at gmail.com>
> Date:   Tue Jun 6 18:34:23 2017 +0200
>
>     Update ffserver.c

The first line should summarize the commit
that says too little and is too generic


>
>     This patch fixes a floating point exception. You are not allowed to defide by zero (FPE)

This is missing an explanation of how/why the variables are 0
Its important in judging if the fix is correct.

also patches should be sent to the mailing list not just linked to


>
> diff --git a/ffserver.c b/ffserver.c
> index f9f987acac..2faa4bc06a 100644
> --- a/ffserver.c
> +++ b/ffserver.c
> @@ -466,7 +466,7 @@ static void update_datarate(DataRateData *drd, int64_t count)
>  /* In bytes per second */
>  static int compute_datarate(DataRateData *drd, int64_t count)
>  {
> -    if (cur_time == drd->time1)
> +    if (cur_time == drd->time1 || cur_time == 0 || drd->time1 == 0)
>          return 0;
>
>      return ((count - drd->count1) * 1000) / (cur_time - drd->time1);
> @@ -1905,10 +1905,16 @@ static inline void print_stream_params(AVIOContext *pb, FFServerStream *stream)
>              break;
>          case AVMEDIA_TYPE_VIDEO:
>              type = "video";
> -            snprintf(parameters, sizeof(parameters),
> -                     "%dx%d, q=%d-%d, fps=%d", st->codecpar->width,
> -                     st->codecpar->height, st->codec->qmin, st->codec->qmax,
> -                     st->time_base.den / st->time_base.num);
> +            if (st->time_base.num != 0) {
> +                snprintf(parameters, sizeof(parameters),
> +                         "%dx%d, q=%d-%d, fps=%d", st->codecpar->width,
> +                         st->codecpar->height, st->codec->qmin, st->codec->qmax,
> +                         st->time_base.den / st->time_base.num);
> +            } else {
> +                snprintf(parameters, sizeof(parameters),
> +                         "%dx%d, q=%d-%d, fps=0", st->codecpar->width,
> +                         st->codecpar->height, st->codec->qmin, st->codec->qmax);
> +            }
>              break;
>          default:
>              abort();
>
>

> 
> I hope it helps!
> 
> Kind regards,
> 
> Robert Nagtegaal
> Alias: Masikh
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170616/5496a96b/attachment.sig>


More information about the ffmpeg-devel mailing list