[FFmpeg-devel] [PATCH] check for mod by zero (issue 2502)

Justin Ruggles justin.ruggles
Fri Jan 7 21:06:32 CET 2011

On 01/07/2011 02:47 PM, Daniel Kang wrote:

> On Fri, Jan 7, 2011 at 11:00 AM, Justin Ruggles <justin.ruggles at gmail.com>wrote:
>> On 01/07/2011 09:52 AM, Daniel Kang wrote:
>> it seems the codec_id does change.
>> voc_get_packet() changes the codec_id based on packet data.  So I think
>> a fix needs to go there.
>> but maybe pcm.c also needs a check for sample_size != 0 before
>> n = avctx->channels * sample_size.
>> -Justin
> Adding a check (by itself) does not stop the crash, it simply prints an
> error. This would give more information though. If the codec_id is
> invalid, what should the behavior be? Is this sufficient?

In voc_get_packet(), if codec_id is invalid, don't read the packet.
or alternatively, set it only once for the first valid value, then later
instead of changing it if the value changes just print a warning and
read the packet.

In pcm.c if codec_id is invalid, don't try to decode the packet. It will
screw up more than just the divide-by-zero.


More information about the ffmpeg-devel mailing list