1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/rtpenc_mpegts: stop leaks

Fixes CID 1474460 & 1474461
This commit is contained in:
Gyan Doshi 2021-03-28 15:05:37 +05:30
parent 1d1a96acf5
commit 8b2bde0494

View File

@ -87,8 +87,11 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
av_dict_copy(&mpegts_muxer_options, chain->mpegts_muxer_options, 0); av_dict_copy(&mpegts_muxer_options, chain->mpegts_muxer_options, 0);
if ((ret = avformat_write_header(mpegts_ctx, &mpegts_muxer_options)) < 0) ret = avformat_write_header(mpegts_ctx, &mpegts_muxer_options);
av_dict_free(&mpegts_muxer_options);
if (ret < 0)
goto fail; goto fail;
for (i = 0; i < s->nb_streams; i++) for (i = 0; i < s->nb_streams; i++)
s->streams[i]->time_base = mpegts_ctx->streams[i]->time_base; s->streams[i]->time_base = mpegts_ctx->streams[i]->time_base;
@ -111,8 +114,11 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS; st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS;
rtp_ctx->pb = s->pb; rtp_ctx->pb = s->pb;
av_dict_copy(&rtp_muxer_options, chain->rtp_muxer_options, 0); av_dict_copy(&rtp_muxer_options, chain->rtp_muxer_options, 0);
if ((ret = avformat_write_header(rtp_ctx, &rtp_muxer_options)) < 0) ret = avformat_write_header(rtp_ctx, &rtp_muxer_options);
av_dict_free(&rtp_muxer_options);
if (ret < 0)
goto fail; goto fail;
chain->rtp_ctx = rtp_ctx; chain->rtp_ctx = rtp_ctx;
return 0; return 0;
@ -121,10 +127,8 @@ fail:
if (mpegts_ctx) { if (mpegts_ctx) {
ffio_free_dyn_buf(&mpegts_ctx->pb); ffio_free_dyn_buf(&mpegts_ctx->pb);
av_dict_free(&mpegts_ctx->metadata); av_dict_free(&mpegts_ctx->metadata);
av_dict_free(&mpegts_muxer_options);
avformat_free_context(mpegts_ctx); avformat_free_context(mpegts_ctx);
} }
av_dict_free(&rtp_muxer_options);
avformat_free_context(rtp_ctx); avformat_free_context(rtp_ctx);
rtp_mpegts_write_close(s); rtp_mpegts_write_close(s);
return ret; return ret;