summaryrefslogtreecommitdiffstats
path: root/libavformat/rtpenc_mpegts.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2015-03-09 23:14:19 +0200
committerMartin Storsjö <martin@martin.st>2015-03-10 09:58:41 +0200
commitcf402d6fa88acd647cdff993429583bec8a34fdc (patch)
tree106bdddf23ef104dc424002c09f80f0f62046d40 /libavformat/rtpenc_mpegts.c
parentc83dd2d2a458075a58895c384372f57c1ec26276 (diff)
downloadffmpeg-streaming-cf402d6fa88acd647cdff993429583bec8a34fdc.zip
ffmpeg-streaming-cf402d6fa88acd647cdff993429583bec8a34fdc.tar.gz
rtpenc_mpegts: Set chain->rtp_ctx only after avformat_write_header succeeded
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. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtpenc_mpegts.c')
-rw-r--r--libavformat/rtpenc_mpegts.c3
1 files changed, 1 insertions, 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;
OpenPOWER on IntegriCloud