[Ffmpeg-devel] [Ffmpeg-devel-old] Division by 0 in av_frac_add()

Guillaume POIRIER poirierg
Tue Oct 4 18:11:32 CEST 2005


Hi,

On 10/3/05, Nico Sabbi <nsabbi at tiscali.it> wrote:

> av_frad_add() doesn't check that f->den != 0; this leads to SIGFPE.
>
> debugging a part of mencoder that recently crashes, and comparing it
> with the last
> working revision, I discovered what follows:
>
> assigning:
>
> AVCodecContext *ctx;
> ctx->width = stream->bih->biWidth;
> ctx->height = stream->bih->biHeight;
>
> when ctx->width = ctx->height = 0 (non-sense but unfortunately true)
> and soon after calling av_write_header() mencoder dies with SIGFPE because
> av_frac_add() assigns:
>
> f->val += num / den; with den==0.
>
> The same code in mencoder, although buggy, worked without problems in
> 1.0pre7.
>
> Adding
>
>     if(!den) return;
>
> on top av_frac_add() fixes the code; I don't know if it's the right
> solution, but preventing
> an invalid operation sounds reasonable in any case.

Attached is the fix Nico suggested.

Somehow, I think this fix should feature some code that assigns
"f->val" and "f->num" with some values but I don't know what...

Guillaume

--
Reading doesn't hurt, really!
  -- Dominik 'Rathann' Mierzejewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: please_don_t_sigfpe.patch
Type: application/octet-stream
Size: 541 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20051004/44eb9f76/attachment.obj>



More information about the ffmpeg-devel mailing list