[FFmpeg-devel] Fix coredump when writing trailer to file with no streams added

Art Clarke aclarke
Thu Jun 19 21:51:00 CEST 2008


On Thu, Jun 19, 2008 at 3:24 PM, Michael Niedermayer <michaelni at gmx.at>
wrote:

> On Thu, Jun 19, 2008 at 01:40:06PM -0400, Art Clarke wrote:
> > Hi there,
> >
> > Ffmpeg core-dumps if you do an av_write_header() and then an
> > av_write_trailer() without first adding at least one stream to the output
> > file.
> >
> > While in theory users should NEVER output a file with no streams in it,
> > core-dumping seems like the wrong thing to do.  The fix just checks to
> make
> > sure there is at least one stream before we start returning cached
> packets
> > to write.
> >
> > Also attached is a test case file that generates the crash before the
> fix,
> > and shows that everything runs smoothly after the fix.
> >
> > Please let me know if this passes the bar for a fix, is rejected, or if
> in
> > between, what I need to do to fix it up right.
> >
> > Thanks,
> >
> > - Art
>
> > Index: libavformat/utils.c
> > ===================================================================
> > --- libavformat/utils.c       (revision 13819)
> > +++ libavformat/utils.c       (working copy)
> > @@ -2551,7 +2551,7 @@
> >          pktl= pktl->next;
> >      }
> >
> > -    if(s->nb_streams == stream_count || (flush && stream_count)){
> > +    if(stream_count && s->nb_streams == stream_count || (flush &&
> stream_count)){
>
> this check can be simplified
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> I hate to see young programmers poisoned by the kind of thinking
> Ulrich Drepper puts forward since it is simply too narrow -- Roman
> Shaposhnik
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFIWrJRYR7HhwQLD6sRAmmuAJ4skdvhH1NizBP3AOUF1uV0ilwqOQCcCS4v
> PbWDJpqY9jhAzsUQStdF8RA=
> =q7rf
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>

Fair enough.  Attempt #2.  Same test case applies.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080619/72f73595/attachment.txt>



More information about the ffmpeg-devel mailing list