[FFmpeg-devel] [libav-devel] [PATCH 2/2] rtpenc_mpegts: Set chain->rtp_ctx only after avformat_write_header succeeded

Michael Niedermayer michaelni at gmx.at
Tue Mar 10 11:48:19 CET 2015


On Mon, Mar 09, 2015 at 11:18:30PM +0100, Andreas Cadhalpun wrote:
> On 09.03.2015 22:15, Martin Storsjö wrote:
> >By making sure we at each time only have one pointer set, either a
> >local variable or one in the context, we avoid potential double frees
> >in the cleanup routines. If chain->rtp_ctx is set, it is closed by
> >calling avformat_write_trailer, but that shouldn't be called unless
> >avformat_write_header succeeded.
> >
> >This issue was pointed out by Andreas Cadhalpun.
> >---
> >Andreas, does this seem to fix the issue for you as well?
> 
> Yes, it does.
> 
> >---
> >  libavformat/rtpenc_mpegts.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> >diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c
> >index 8ced6a9..585d1ad 100644
> >--- a/libavformat/rtpenc_mpegts.c
> >+++ b/libavformat/rtpenc_mpegts.c
> >@@ -88,11 +88,10 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
> >      st->time_base.num   = 1;
> >      st->time_base.den   = 90000;
> >      st->codec->codec_id = AV_CODEC_ID_MPEG2TS;
> >-    chain->rtp_ctx = rtp_ctx;
> >      rtp_ctx->pb = s->pb;
> >      if ((ret = avformat_write_header(rtp_ctx, NULL)) < 0)
> >          goto fail;
> >-    rtp_ctx = NULL;
> >+    chain->rtp_ctx = rtp_ctx;
> >
> >      return 0;
> >
> >
> 
> This looks like the proper fix.

merged

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150310/d0061f4b/attachment.asc>


More information about the ffmpeg-devel mailing list