Skip to content

Commit

Permalink
avformat/rtpenc_mpegts: stop leaks
Browse files Browse the repository at this point in the history
Fixes CID 1474460 & 1474461
  • Loading branch information
GyanD committed Mar 28, 2021
1 parent fd80c0b commit 7a74129
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions libavformat/rtpenc_mpegts.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ static int rtp_mpegts_write_header(AVFormatContext *s)

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;

for (i = 0; i < s->nb_streams; i++)
s->streams[i]->time_base = mpegts_ctx->streams[i]->time_base;

Expand All @@ -111,8 +114,11 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS;
rtp_ctx->pb = s->pb;
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;

chain->rtp_ctx = rtp_ctx;

return 0;
Expand All @@ -121,10 +127,8 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
if (mpegts_ctx) {
ffio_free_dyn_buf(&mpegts_ctx->pb);
av_dict_free(&mpegts_ctx->metadata);
av_dict_free(&mpegts_muxer_options);
avformat_free_context(mpegts_ctx);
}
av_dict_free(&rtp_muxer_options);
avformat_free_context(rtp_ctx);
rtp_mpegts_write_close(s);
return ret;
Expand Down

0 comments on commit 7a74129

Please sign in to comment.