[FFmpeg-devel] [PATCH] Fix double free causing segmentation faults when accessing unavailable v4l devices

Stefano Sabatini stefano.sabatini-lala
Tue Jul 15 22:48:53 CEST 2008


On date Tuesday 2008-07-15 21:58:30 +0200, Michael Niedermayer encoded:
> On Tue, Jul 15, 2008 at 09:39:01PM +0200, Stefano Sabatini wrote:
> > Hi all, as in subject,
> > you may experience the crashes for example with:
> > ffmpeg -f video4linux2 -s 640x480 -r 25 -i /dev/video0
> > 
> > if there is no video4linux device connected to the machine (no
> > /dev/video0 file).
> > 
> > This happens because the v4l2?_read_header() functions call av_free() on
> > the new stream, then av_open_input_stream() call av_free() again in case
> > of failure on the already alloced stream:
> > 
> >  fail:
> >     if (ic) {
> >         int i;
> >         av_freep(&ic->priv_data);
> >         for(i=0;i<ic->nb_streams;i++) {
> >             AVStream *st = ic->streams[i];
> >             if (st) {
> >                 av_free(st->priv_data);
> >                 av_free(st->codec->extradata);
> >             }
> >             av_free(st);
> >         }
> >     }
> >     av_free(ic);
> >     *ic_ptr = NULL;
> >     return err;
> > 
> > Another possible solution could be to use avfreep(&st) in 
> > v4l?.c, but I think this solution is more correct.
> 
> patches ok

Applied.
-- 
FFmpeg = Furious and Furious Multimedia Porno Ecletic God




More information about the ffmpeg-devel mailing list