[FFmpeg-devel] [Patch] Fix crash in avienc when muxing zero streams

Benoit Fouet benoit.fouet
Wed Jan 13 15:33:09 CET 2010


On Wed, 13 Jan 2010 14:08:44 +0100 Michael Niedermayer wrote:
> On Wed, Jan 13, 2010 at 10:14:47AM +0100, Tomas H?rdin wrote:
> > On Tue, 2010-01-12 at 23:40 +0100, Michael Niedermayer wrote:
> > > On Tue, Jan 12, 2010 at 04:26:03PM +0100, Tomas H?rdin wrote:
> > > > Good evening
> > > > 
> > > > I've noticed a bug in libavformat/avienc.c - avi_write_header()
> > > > segfaults when the number of streams is zero. The culprit is line 363,
> > > > which is missing a NULL pointer check on s->streams[0]. Zero streams
> > > > should be semantically equal to CODEC_FLAG_BITEXACT not being set, so I
> > > > simply prepended "!s->streams[0] ||". Some might prefer nb_streams == 0
> > > > though.
> > > > 
> > > > There are more examples of this behaviour. Try searching for streams[0]
> > > > and you'll find more (soxenc.c for instance). That's probably for
> > > > another day though.
> > > > 
> > > > Attached patch passes the tests.
> > > 
> > > what use is a avi file with no streams?
> > > none? then  the check belongs in the common code to prevent this case
> > > from ever reaching any muxer
> > 
> > That would be an easier solution - one which I initially considered.
> > However, output without streams is not useless - there's plenty of
> > metadata around. Also, if URIs to external essences are not considered
> > part of a stream, then an MXF or MOV file containing only such essence
> > would have no streams (if such support is added in the future).
> > Therefore I opted for the solution which retains maximum functionality
> > of lavf.
> > 
> > However, I also made another patch which adds a check in
> > av_write_header(). It also passes the tests. See utils.diff.
> > 
> > /Tomas
> > 
> 
> >  utils.c |    5 +++++
> >  1 file changed, 5 insertions(+)
> > 919f47f16397707a1c9088818d631fbc72c98e25  utils.diff
> 
> ok
> 

Applied

Ben



More information about the ffmpeg-devel mailing list