diff mbox

[FFmpeg-devel,V1,3/3] lavf/hlsenc: fix memory leak

Message ID 1570842880-22864-3-git-send-email-mypopydev@gmail.com
State Accepted
Commit feaec3bc3133ff143b8445c919f2c4c56048fdf9
Headers show

Commit Message

Jun Zhao Oct. 12, 2019, 1:14 a.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

fix memory leak

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/hlsenc.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Liu Steven Oct. 12, 2019, 3:18 a.m. UTC | #1
> 在 2019年10月12日,09:14,Jun Zhao <mypopydev@gmail.com> 写道:
> 
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> fix memory leak
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
> libavformat/hlsenc.c |    2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index cd43201..5a27b0f 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -585,6 +585,8 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>             av_strlcpy(sub_path, vtt_dirname, sub_path_size);
>             av_strlcat(sub_path, segment->sub_filename, sub_path_size);
> 
> +            av_freep(&vtt_dirname);
> +
>             if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
>                 av_dict_set(&options, "method", "DELETE", 0);
>                 if ((ret = vs->vtt_avf->io_open(vs->vtt_avf, &out, sub_path, AVIO_FLAG_WRITE, &options)) < 0) {
> -- 
> 1.7.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".

This patch should wait Limin Wang’s patch, his patch should fix this problem.
Thanks
Steven
Lance Wang Oct. 12, 2019, 3:50 a.m. UTC | #2
On Sat, Oct 12, 2019 at 11:18:39AM +0800, Steven Liu wrote:
> 
> 
> > 在 2019年10月12日,09:14,Jun Zhao <mypopydev@gmail.com> 写道:
> > 
> > From: Jun Zhao <barryjzhao@tencent.com>
> > 
> > fix memory leak
> > 
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> > libavformat/hlsenc.c |    2 ++
> > 1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> > index cd43201..5a27b0f 100644
> > --- a/libavformat/hlsenc.c
> > +++ b/libavformat/hlsenc.c
> > @@ -585,6 +585,8 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
> >             av_strlcpy(sub_path, vtt_dirname, sub_path_size);
> >             av_strlcat(sub_path, segment->sub_filename, sub_path_size);
> > 
> > +            av_freep(&vtt_dirname);
> > +
> >             if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
> >                 av_dict_set(&options, "method", "DELETE", 0);
> >                 if ((ret = vs->vtt_avf->io_open(vs->vtt_avf, &out, sub_path, AVIO_FLAG_WRITE, &options)) < 0) {
> > -- 
> > 1.7.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".
> 
> This patch should wait Limin Wang’s patch, his patch should fix this problem.
> Thanks
> Steven

The free is necessary, just need to use origianl vtt_dirname_r as it's in loop.
I'd like to ask for zhao jun to help merge both to sumit a complete fix patch.
I'm using valgrind for testing last time, I'm not clear why it's doesn't report
this leaks.

> 
> 
> 
> 
> 
> _______________________________________________
> 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".
Liu Steven Oct. 12, 2019, 3:54 a.m. UTC | #3
> 在 2019年10月12日,11:50,Limin Wang <lance.lmwang@gmail.com> 写道:
> 
> On Sat, Oct 12, 2019 at 11:18:39AM +0800, Steven Liu wrote:
>> 
>> 
>>> 在 2019年10月12日,09:14,Jun Zhao <mypopydev@gmail.com> 写道:
>>> 
>>> From: Jun Zhao <barryjzhao@tencent.com>
>>> 
>>> fix memory leak
>>> 
>>> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
>>> ---
>>> libavformat/hlsenc.c |    2 ++
>>> 1 files changed, 2 insertions(+), 0 deletions(-)
>>> 
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index cd43201..5a27b0f 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -585,6 +585,8 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>>>            av_strlcpy(sub_path, vtt_dirname, sub_path_size);
>>>            av_strlcat(sub_path, segment->sub_filename, sub_path_size);
>>> 
>>> +            av_freep(&vtt_dirname);
>>> +
>>>            if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
>>>                av_dict_set(&options, "method", "DELETE", 0);
>>>                if ((ret = vs->vtt_avf->io_open(vs->vtt_avf, &out, sub_path, AVIO_FLAG_WRITE, &options)) < 0) {
>>> -- 
>>> 1.7.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".
>> 
>> This patch should wait Limin Wang’s patch, his patch should fix this problem.
>> Thanks
>> Steven
> 
> The free is necessary, just need to use origianl vtt_dirname_r as it's in loop.
> I'd like to ask for zhao jun to help merge both to sumit a complete fix patch.
> I'm using valgrind for testing last time, I'm not clear why it's doesn't report
> this leaks.
> 
Hi Jun Zhao,

	you can merge his patch to your patch.
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> 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".

Thanks
Steven
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cd43201..5a27b0f 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -585,6 +585,8 @@  static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
             av_strlcpy(sub_path, vtt_dirname, sub_path_size);
             av_strlcat(sub_path, segment->sub_filename, sub_path_size);
 
+            av_freep(&vtt_dirname);
+
             if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
                 av_dict_set(&options, "method", "DELETE", 0);
                 if ((ret = vs->vtt_avf->io_open(vs->vtt_avf, &out, sub_path, AVIO_FLAG_WRITE, &options)) < 0) {