diff mbox

[FFmpeg-devel,v1,08/11] avformat/rtmpproto: fix memleak when open rtmp failed

Message ID 20191009073530.4505-8-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu Oct. 9, 2019, 7:35 a.m. UTC
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/rtmpproto.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Lance Wang Oct. 9, 2019, 2:31 p.m. UTC | #1
On Wed, Oct 09, 2019 at 03:35:27PM +0800, Steven Liu wrote:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/rtmpproto.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
> index eb08d4d424..ae5eef8bca 100644
> --- a/libavformat/rtmpproto.c
> +++ b/libavformat/rtmpproto.c
> @@ -2880,6 +2880,12 @@ reconnect:
>      return 0;
>  
>  fail:
> +    if (rt->playpath)
> +        av_free(rt->playpath);
> +    if (rt->tcurl)
> +        av_free(rt->tcurl);
> +    if (rt->flashver)
> +        av_free(rt->flashver);

it's better to use av_freep

>      av_dict_free(opts);
>      rtmp_close(s);
>      return ret;
> -- 
> 2.15.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".
Paul B Mahol Oct. 9, 2019, 2:33 p.m. UTC | #2
On 10/9/19, Limin Wang <lance.lmwang@gmail.com> wrote:
> On Wed, Oct 09, 2019 at 03:35:27PM +0800, Steven Liu wrote:
>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>> ---
>>  libavformat/rtmpproto.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
>> index eb08d4d424..ae5eef8bca 100644
>> --- a/libavformat/rtmpproto.c
>> +++ b/libavformat/rtmpproto.c
>> @@ -2880,6 +2880,12 @@ reconnect:
>>      return 0;
>>
>>  fail:
>> +    if (rt->playpath)
>> +        av_free(rt->playpath);
>> +    if (rt->tcurl)
>> +        av_free(rt->tcurl);
>> +    if (rt->flashver)
>> +        av_free(rt->flashver);
>
> it's better to use av_freep

also ifs are not needed.

>
>>      av_dict_free(opts);
>>      rtmp_close(s);
>>      return ret;
>> --
>> 2.15.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".
> _______________________________________________
> 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".
diff mbox

Patch

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index eb08d4d424..ae5eef8bca 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2880,6 +2880,12 @@  reconnect:
     return 0;
 
 fail:
+    if (rt->playpath)
+        av_free(rt->playpath);
+    if (rt->tcurl)
+        av_free(rt->tcurl);
+    if (rt->flashver)
+        av_free(rt->flashver);
     av_dict_free(opts);
     rtmp_close(s);
     return ret;