Hi,

trying to encode e.g. codec bmp with format rtp_mpegts crashes, because the avformat_write_header failure isn't handled correctly.
Attached is a patch fixing this.

Best regards,
Andreas
>From c0ba3afc828bc6255a1bcf0feb34af3caa892572 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Mon, 9 Mar 2015 21:09:25 +0100
Subject: [PATCH] rtpenc_mpegts: set rtp_ctx to NULL on avformat_write_header
 failure

If avformat_write_header fails, rtp_ctx is not set to NULL, thus it is
freed in the fail goto. This leaves chain->rtp_ctx as a stale pointer to the
freed context, leading to a crash in rtp_mpegts_write_close.

Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
---
 libavformat/rtpenc_mpegts.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c
index 5b94e73..3bb06d5 100644
--- a/libavformat/rtpenc_mpegts.c
+++ b/libavformat/rtpenc_mpegts.c
@@ -90,9 +90,10 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
     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;
+    ret = avformat_write_header(rtp_ctx, NULL);
     rtp_ctx = NULL;
+    if (ret < 0)
+        goto fail;
 
     return 0;
 
-- 
2.1.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to