[Ffmpeg-devel] Divide by zero in av_reduce - Possible Bug

Michael Niedermayer michaelni
Thu May 25 12:27:43 CEST 2006


On Thu, May 25, 2006 at 11:31:05AM +0200, Ian McIntosh wrote:
> Hi
> I had an mpeg2 (Elementary Video Stream) source that had quite a few 
> errors in the stream. While decoding using the ffmpeg library, my 
> program would crash with a divide by zero error. Looking at the 
> backtrace I noticed that in mpeg12.c the frame_rate_index was 0 just 
> before calling av_reduce. The result of this is that the 'nom' and 'den' 
> parameters in av_reduce are 0 which ends up making the 'gcd' variable 
> inside av_reduce (rational.c) 0, which is later used as a divisor in 
> another calculation which equals core dump.
> Anyway it turns out that in the mpeg2 source stream there was an error 
> with the 'frame rate code' bits in one of the sequence headers (they 
> were 0 for some reason). A quick hack to fix this was to check the 
> frame_rate_index just before the av_reduce function call and set it to 
> some valid value if it was 0. This resolved the problem, but I was 
> thinking that there is probably a better way to handle this condition. 
> Anyone have any thoughts on the matter or suggestions for a fix ?

current cvs checks for 0 after reading, if it still uses the value
afterwards thats a bug



In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is

More information about the ffmpeg-devel mailing list