[FFmpeg-devel] utils.c patch to avoid divide by zero

Frank Barchard fbarchard
Wed Aug 26 07:11:45 CEST 2009


On Tue, Aug 25, 2009 at 9:04 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
>
> On Tue, Aug 25, 2009 at 06:20:47PM -0700, Frank Barchard wrote:
> > This patch avoids a divide by zero crash. ?It follows the same convention as
> > a similar check a few lines above.
>
> your patch is mangled besides, how and where does this bug happen
> i dont think the solution suggested in your patch is correct but i
> first need to know what the exact issue is

It was an ogv crash, but I missed a change may 3 that fixes it at a
higher level:
http://git.ffmpeg.org/?p=ffmpeg;a=commitdiff;h=d314d12ff724fd678e8e99f5b5359e39695ace7b
Is it best to have each codec avoid the divide by zero, or change it in util.c?
To get the diff I used
svn diff libavformat/utils.c

Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c (revision 19708)
+++ libavformat/utils.c (working copy)
@@ -1637,7 +1637,7 @@
                     end_time = end_time1;
             }
         }
-        if (st->duration != AV_NOPTS_VALUE) {
+        if (st->duration != AV_NOPTS_VALUE && st->time_base.den) {
             duration1 = av_rescale_q(st->duration, st->time_base,
AV_TIME_BASE_Q);
             if (duration1 > duration)
                 duration = duration1;



More information about the ffmpeg-devel mailing list