diff mbox series

[FFmpeg-devel] avformat/rtpenc_mpegts: stop leaks

Message ID 20210328093730.2754-1-ffmpeg@gyani.pro
State Accepted
Commit 8b2bde04948e6e10896b6f923b0367aaba153014
Headers show
Series [FFmpeg-devel] avformat/rtpenc_mpegts: stop leaks | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Gyan Doshi March 28, 2021, 9:37 a.m. UTC
Fixes CID 1474460 & 1474461
---
 libavformat/rtpenc_mpegts.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Marton Balint March 28, 2021, 10:22 a.m. UTC | #1
On Sun, 28 Mar 2021, Gyan Doshi wrote:

> Fixes CID 1474460 & 1474461
> ---
> libavformat/rtpenc_mpegts.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)

LGTM, thanks.

Marton

>
> diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c
> index f7ee5a4448..9f95b3a4e8 100644
> --- a/libavformat/rtpenc_mpegts.c
> +++ b/libavformat/rtpenc_mpegts.c
> @@ -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;
> 
> @@ -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;
> @@ -121,10 +127,8 @@ fail:
>     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;
> -- 
> 2.30.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Gyan Doshi March 28, 2021, 10:27 a.m. UTC | #2
On 2021-03-28 15:52, Marton Balint wrote:
>
>
> On Sun, 28 Mar 2021, Gyan Doshi wrote:
>
>> Fixes CID 1474460 & 1474461
>> ---
>> libavformat/rtpenc_mpegts.c | 12 ++++++++----
>> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> LGTM, thanks.

Thanks.

Pushed as 8b2bde04948e6e10896b6f923b0367aaba153014 to master

and as 7a74129fa91d36450b02e605d0756375aababd1b to 4.4

Regards,
Gyan
diff mbox series

Patch

diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c
index f7ee5a4448..9f95b3a4e8 100644
--- a/libavformat/rtpenc_mpegts.c
+++ b/libavformat/rtpenc_mpegts.c
@@ -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;
 
@@ -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;
@@ -121,10 +127,8 @@  fail:
     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;