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

Ian McIntosh ianm
Fri May 26 11:51:49 CEST 2006


Michael Niedermayer wrote:
> Hi
> 
> 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
> 
> 
> [...]
> 

I was using a version that was slightly old - managed to update to the 
latest version and issue has disappeared...... I apologise for the false 
alarm - should have updated before posting

Thanks
Ian




More information about the ffmpeg-devel mailing list