[FFmpeg-devel,v1,02/11] avformat/hlsenc: fix memleak of vtt_dirname_r in hls_delete_old_segments

Submitted by Steven Liu on Oct. 9, 2019, 7:35 a.m.

Details

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

Commit Message

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

Comments

lance.lmwang@gmail.com Oct. 9, 2019, 8:36 a.m.
On Wed, Oct 09, 2019 at 03:35:21PM +0800, Steven Liu wrote:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/hlsenc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index a1c03dbed5..a689acc2e0 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -575,6 +575,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>          if ((segment->sub_filename[0] != '\0')) {
>              char *vtt_dirname_r = av_strdup(vs->vtt_avf->url);
>              vtt_dirname = (char*)av_dirname(vtt_dirname_r);
> +            av_freep(&vtt_dirname_r);

vtt_dirname use the memory still so you can't free it here, the current code try to free
by vtt_dirname, it's not correct. I have send  my changes to support system interface, you
can help to review the patchset.

>              sub_path_size = strlen(segment->sub_filename) + 1 + strlen(vtt_dirname);
>              sub_path = av_malloc(sub_path_size);
>              if (!sub_path) {
> -- 
> 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".
Steven Liu Oct. 9, 2019, 8:43 a.m.
> 在 2019年10月9日,16:36,Limin Wang <lance.lmwang@gmail.com> 写道:
> 
> On Wed, Oct 09, 2019 at 03:35:21PM +0800, Steven Liu wrote:
>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>> ---
>> libavformat/hlsenc.c | 1 +
>> 1 file changed, 1 insertion(+)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index a1c03dbed5..a689acc2e0 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -575,6 +575,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>>         if ((segment->sub_filename[0] != '\0')) {
>>             char *vtt_dirname_r = av_strdup(vs->vtt_avf->url);
>>             vtt_dirname = (char*)av_dirname(vtt_dirname_r);
>> +            av_freep(&vtt_dirname_r);
> 
> vtt_dirname use the memory still so you can't free it here, the current code try to free
> by vtt_dirname, it's not correct. I have send  my changes to support system interface, you
> can help to review the patchset.
ok, this patch will not apply
> 
>>             sub_path_size = strlen(segment->sub_filename) + 1 + strlen(vtt_dirname);
>>             sub_path = av_malloc(sub_path_size);
>>             if (!sub_path) {
>> -- 
>> 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".

Thanks
Steven

Patch hide | download patch | download mbox

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a1c03dbed5..a689acc2e0 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -575,6 +575,7 @@  static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
         if ((segment->sub_filename[0] != '\0')) {
             char *vtt_dirname_r = av_strdup(vs->vtt_avf->url);
             vtt_dirname = (char*)av_dirname(vtt_dirname_r);
+            av_freep(&vtt_dirname_r);
             sub_path_size = strlen(segment->sub_filename) + 1 + strlen(vtt_dirname);
             sub_path = av_malloc(sub_path_size);
             if (!sub_path) {