[FFmpeg-devel] avformat/hlsenc: remove duplicate code block

Submitted by Steven Liu on Nov. 27, 2019, 9:43 a.m.

Details

Message ID 20191127094309.25156-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu Nov. 27, 2019, 9:43 a.m.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/hlsenc.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

Comments

Michael Niedermayer Nov. 27, 2019, 8:06 p.m.
On Wed, Nov 27, 2019 at 05:43:09PM +0800, Steven Liu wrote:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/hlsenc.c | 23 ++++-------------------
>  1 file changed, 4 insertions(+), 19 deletions(-)

this breaks the code

./ffmpeg_g -i mm-short.mpg -i fate-suite/sub/MovText_capability_tester.mp4  -f hls  -c:a aac -hls_segment_filename /tmp/file-v.low.%d.ts -t 10 /tmp/file-v.low.m3u8

...
==5612== Invalid read of size 8
==5612==    at 0x800AC8: avformat_free_context (in ffmpeg/ffmpeg_g)
==5612==    by 0x710A9B: hls_free_variant_streams.isra.12 (in ffmpeg/ffmpeg_g)
==5612==    by 0x714EB3: hls_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x78341A: av_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x4D9E88: transcode (in ffmpeg/ffmpeg_g)
==5612==    by 0x4B5D3C: main (in ffmpeg/ffmpeg_g)
==5612==  Address 0x464b0c50 is 16 bytes inside a block of size 1,504 free'd
==5612==    at 0x4C2B5D9: free (vg_replace_malloc.c:446)
==5612==    by 0x800D97: avformat_free_context (in ffmpeg/ffmpeg_g)
==5612==    by 0x714AF9: hls_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x78341A: av_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x4D9E88: transcode (in ffmpeg/ffmpeg_g)
==5612==    by 0x4B5D3C: main (in ffmpeg/ffmpeg_g)
==5612== 
==5612== Invalid read of size 8
==5612==    at 0x119430E: av_opt_free (in ffmpeg/ffmpeg_g)
==5612==    by 0x800AF6: avformat_free_context (in ffmpeg/ffmpeg_g)
==5612==    by 0x710A9B: hls_free_variant_streams.isra.12 (in ffmpeg/ffmpeg_g)
==5612==    by 0x714EB3: hls_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x78341A: av_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x4D9E88: transcode (in ffmpeg/ffmpeg_g)
==5612==    by 0x4B5D3C: main (in ffmpeg/ffmpeg_g)
==5612==  Address 0x464b0c40 is 0 bytes inside a block of size 1,504 free'd
==5612==    at 0x4C2B5D9: free (vg_replace_malloc.c:446)
==5612==    by 0x800D97: avformat_free_context (in ffmpeg/ffmpeg_g)
==5612==    by 0x714AF9: hls_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x78341A: av_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x4D9E88: transcode (in ffmpeg/ffmpeg_g)
==5612==    by 0x4B5D3C: main (in ffmpeg/ffmpeg_g)
==5612== 
==5612== Invalid read of size 8
==5612==    at 0x118EBA3: av_freep (in ffmpeg/ffmpeg_g)
==5612==    by 0x119434E: av_opt_free (in ffmpeg/ffmpeg_g)
==5612==    by 0x800AF6: avformat_free_context (in ffmpeg/ffmpeg_g)
==5612==    by 0x710A9B: hls_free_variant_streams.isra.12 (in ffmpeg/ffmpeg_g)
==5612==    by 0x714EB3: hls_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x78341A: av_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x4D9E88: transcode (in ffmpeg/ffmpeg_g)
==5612==    by 0x4B5D3C: main (in ffmpeg/ffmpeg_g)
==5612==  Address 0x464b10b8 is 1,144 bytes inside a block of size 1,504 free'd
==5612==    at 0x4C2B5D9: free (vg_replace_malloc.c:446)
==5612==    by 0x800D97: avformat_free_context (in ffmpeg/ffmpeg_g)
==5612==    by 0x714AF9: hls_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x78341A: av_write_trailer (in ffmpeg/ffmpeg_g)
==5612==    by 0x4D9E88: transcode (in ffmpeg/ffmpeg_g)
==5612==    by 0x4B5D3C: main (in ffmpeg/ffmpeg_g)

If you cannot reproduce, tell me and ill rerun this with full debug symbols (line numbers)

thx

[...]
Steven Liu Nov. 28, 2019, 3:26 a.m.
> 在 2019年11月28日,04:06,Michael Niedermayer <michael@niedermayer.cc> 写道:
> 
> mm-short.mpg
Hi Michael,

	Where should i download the file mm-short.mpg?

Thanks
Steven
Michael Niedermayer Nov. 28, 2019, 6:48 p.m.
On Thu, Nov 28, 2019 at 11:26:24AM +0800, Steven Liu wrote:
> 
> 
> > 在 2019年11月28日,04:06,Michael Niedermayer <michael@niedermayer.cc> 写道:
> > 
> > mm-short.mpg
> Hi Michael,
> 
> 	Where should i download the file mm-short.mpg?

you can make it yourself, it is just:

dd if=matrixbench_mpeg2.mpg of=mm-short.mpg count=4000

db7c44ab3d2b75d6e61fe61b1a595b31  mm-short.mpg

[...]
Steven Liu Nov. 28, 2019, 11:42 p.m.
> 在 2019年11月29日,上午2:48,Michael Niedermayer <michael@niedermayer.cc> 写道:
> 
> On Thu, Nov 28, 2019 at 11:26:24AM +0800, Steven Liu wrote:
>> 
>> 
>>> 在 2019年11月28日,04:06,Michael Niedermayer <michael@niedermayer.cc> 写道:
>>> 
>>> mm-short.mpg
>> Hi Michael,
>> 
>> 	Where should i download the file mm-short.mpg?
> 
> you can make it yourself, it is just:
> 
> dd if=matrixbench_mpeg2.mpg of=mm-short.mpg count=4000

StevenLiu:dash StevenLiu$ find fate-suite -name matrixbench_mpeg2.mpg
StevenLiu:dash StevenLiu$
There have no file named matrixbench_mpeg2.mpg, 
I ask for the mpg file for: i want to know what contents of the mpg file, just video stream? audio stream? or other stream? 


Whatever, i will resubmit a new version patch, try to fix this problem.

> 
> db7c44ab3d2b75d6e61fe61b1a595b31  mm-short.mpg
> 

Thanks
Steven
Carl Eugen Hoyos Nov. 28, 2019, 11:55 p.m.
Am Fr., 29. Nov. 2019 um 00:43 Uhr schrieb Liu Steven <lq@chinaffmpeg.org>:
>
>
>
> > 在 2019年11月29日,上午2:48,Michael Niedermayer <michael@niedermayer.cc> 写道:
> >
> > On Thu, Nov 28, 2019 at 11:26:24AM +0800, Steven Liu wrote:
> >>
> >>
> >>> 在 2019年11月28日,04:06,Michael Niedermayer <michael@niedermayer.cc> 写道:
> >>>
> >>> mm-short.mpg
> >> Hi Michael,
> >>
> >>      Where should i download the file mm-short.mpg?
> >
> > you can make it yourself, it is just:
> >
> > dd if=matrixbench_mpeg2.mpg of=mm-short.mpg count=4000
>
> StevenLiu:dash StevenLiu$ find fate-suite -name matrixbench_mpeg2.mpg

https://samples.ffmpeg.org/benchmark/testsuite1/

Carl Eugen
Steven Liu Nov. 29, 2019, 2:44 a.m.
> 在 2019年11月29日,07:55,Carl Eugen Hoyos <ceffmpeg@gmail.com> 写道:
> 
> Am Fr., 29. Nov. 2019 um 00:43 Uhr schrieb Liu Steven <lq@chinaffmpeg.org>:
>> 
>> 
>> 
>>> 在 2019年11月29日,上午2:48,Michael Niedermayer <michael@niedermayer.cc> 写道:
>>> 
>>> On Thu, Nov 28, 2019 at 11:26:24AM +0800, Steven Liu wrote:
>>>> 
>>>> 
>>>>> 在 2019年11月28日,04:06,Michael Niedermayer <michael@niedermayer.cc> 写道:
>>>>> 
>>>>> mm-short.mpg
>>>> Hi Michael,
>>>> 
>>>>     Where should i download the file mm-short.mpg?
>>> 
>>> you can make it yourself, it is just:
>>> 
>>> dd if=matrixbench_mpeg2.mpg of=mm-short.mpg count=4000
>> 
>> StevenLiu:dash StevenLiu$ find fate-suite -name matrixbench_mpeg2.mpg
> 
> https://samples.ffmpeg.org/benchmark/testsuite1/

Thanks Carl :D
> 
> Carl Eugen
> _______________________________________________
> 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
Ruiling Song Nov. 29, 2019, 2:44 a.m.
> -----Original Message-----

> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Liu

> Steven

> Sent: Friday, November 29, 2019 7:42 AM

> To: FFmpeg development discussions and patches <ffmpeg-

> devel@ffmpeg.org>

> Cc: Liu Steven <lq@chinaffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: remove duplicate

> code block

> 

> 

> 

> > 在 2019年11月29日,上午2:48,Michael Niedermayer

> <michael@niedermayer.cc> 写道:

> >

> > On Thu, Nov 28, 2019 at 11:26:24AM +0800, Steven Liu wrote:

> >>

> >>

> >>> 在 2019年11月28日,04:06,Michael Niedermayer

> <michael@niedermayer.cc> 写道:

> >>>

> >>> mm-short.mpg

> >> Hi Michael,

> >>

> >> 	Where should i download the file mm-short.mpg?

> >

> > you can make it yourself, it is just:

> >

> > dd if=matrixbench_mpeg2.mpg of=mm-short.mpg count=4000

> 

> StevenLiu:dash StevenLiu$ find fate-suite -name matrixbench_mpeg2.mpg

> StevenLiu:dash StevenLiu$

> There have no file named matrixbench_mpeg2.mpg,

> I ask for the mpg file for: i want to know what contents of the mpg file, just

> video stream? audio stream? or other stream?

https://samples.ffmpeg.org/benchmark/testsuite1/

> 

> 

> Whatever, i will resubmit a new version patch, try to fix this problem.

> 

> >

> > db7c44ab3d2b75d6e61fe61b1a595b31  mm-short.mpg

> >

> 

> Thanks

> Steven

> 

> 

> 

> _______________________________________________

> 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".

Patch hide | download patch | download mbox

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 043438368e..1105380806 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2486,7 +2486,9 @@  static void hls_free_variant_streams(struct HLSContext *hls)
         if (vtt_oc) {
             av_freep(&vs->vtt_basename);
             av_freep(&vs->vtt_m3u8_name);
+            avformat_free_context(vs->vtt_avf);
         }
+        avformat_free_context(vs->avf);
 
         hls_free_segments(vs->segments);
         hls_free_segments(vs->old_segments);
@@ -2956,31 +2958,14 @@  static int hls_init(AVFormatContext *s)
 
 fail:
     if (ret < 0) {
-        av_freep(&hls->key_basename);
-        for (i = 0; i < hls->nb_varstreams && hls->var_streams; i++) {
-            vs = &hls->var_streams[i];
-            av_freep(&vs->basename);
-            av_freep(&vs->vtt_basename);
-            av_freep(&vs->fmp4_init_filename);
-            av_freep(&vs->m3u8_name);
-            av_freep(&vs->vtt_m3u8_name);
-            av_freep(&vs->streams);
-            av_freep(&vs->language);
-            av_freep(&vs->agroup);
-            av_freep(&vs->ccgroup);
-            av_freep(&vs->baseurl);
-            av_freep(&vs->varname);
-            if (vs->avf)
-                avformat_free_context(vs->avf);
-            if (vs->vtt_avf)
-                avformat_free_context(vs->vtt_avf);
-        }
+        hls_free_variant_streams(hls);
         for (i = 0; i < hls->nb_ccstreams; i++) {
             ClosedCaptionsStream *ccs = &hls->cc_streams[i];
             av_freep(&ccs->ccgroup);
             av_freep(&ccs->instreamid);
             av_freep(&ccs->language);
         }
+        av_freep(&hls->key_basename);
         av_freep(&hls->var_streams);
         av_freep(&hls->cc_streams);
         av_freep(&hls->master_m3u8_url);