Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Soft Works <softworkz-at-hotmail.com@ffmpeg.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 1/2] avformat/hls demuxer: Add WebVTT subtitle support
Date: Fri, 21 Feb 2025 11:56:41 +0000
Message-ID: <DM8P223MB036588C0A9946172DC24F7A9BAC72@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB0744730C91BF3EEA971F36268FC72@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Andreas Rheinhardt
> Sent: Freitag, 21. Februar 2025 10:18
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] avformat/hls demuxer: Add WebVTT
> subtitle support
> 
> softworkz:
> > From: softworkz <softworkz@hotmail.com>
> >

[...]

> >      /* Open the demuxer for each playlist */
> >      for (i = 0; i < c->n_playlists; i++) {
> >          struct playlist *pls = c->playlists[i];
> > @@ -2107,8 +2230,12 @@ static int hls_read_header(AVFormatContext
> *s)
> >              return AVERROR(ENOMEM);
> >          }
> >
> > -        ffio_init_context(&pls->pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0,
> pls,
> > -                          read_data, NULL, NULL);
> > +        if (pls->is_subtitle)
> > +            ffio_init_context(&pls->pb, (unsigned char*)av_strdup(vtt_sample),
> (int)strlen(vtt_sample), 0, pls,
> > +                                        NULL, NULL, NULL);
> > +        else
> > +            ffio_init_context(&pls->pb, pls->read_buffer, INITIAL_BUFFER_SIZE,
> 0, pls,
> > +                                        read_data_continuous, NULL, NULL);
> 
> 1. Unchecked av_strdup().

Yup, thanks.

> 2. Is duplicating the string even needed? Can't we simply set the
> AVIOContext to NULL before closing the AVFormatContext?

The lifetime of these two is not aligned. Also, I wouldn't want to 
make assumptions as to what is being done with that buffer at
other places of the code (where the constant might be subject 
of an attempt to get freed.

[...]

> > +        if (pls->is_subtitle) {
> > +            avformat_free_context(pls->ctx);
> 
> Doesn't the copy of vtt_sample leak here?

Unless I'm overseeing something, the FFIOContext owns the buffer with the
copied vtt_sample string, and that FFIOContext, is owned by the playlist 
(pls->pb). It is freed in free_playlist_list():

	av_freep(&pls->pb.pub.buffer);

In that function it would be ugly to make a distinction depending on which 
type of memory the buffer would be carrying, no?

Thanks
sw

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

  parent reply	other threads:[~2025-02-21 11:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 14:10 [FFmpeg-devel] [PATCH 0/2] " ffmpegagent
2025-02-19 14:10 ` [FFmpeg-devel] [PATCH 1/2] " softworkz
2025-02-21  9:18   ` Andreas Rheinhardt
2025-02-21  9:23     ` Soft Works
2025-02-21 11:56     ` Soft Works [this message]
2025-02-19 14:10 ` [FFmpeg-devel] [PATCH 2/2] avformat/webvttdec: Add webvtt extension and MIME type softworkz
2025-02-21 15:13 ` [FFmpeg-devel] [PATCH v2 0/2] avformat/hls demuxer: Add WebVTT subtitle support ffmpegagent
2025-02-21 15:13   ` [FFmpeg-devel] [PATCH v2 1/2] " softworkz
2025-02-21 15:13   ` [FFmpeg-devel] [PATCH v2 2/2] avformat/webvttdec: Add webvtt extension and MIME type softworkz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM8P223MB036588C0A9946172DC24F7A9BAC72@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM \
    --to=softworkz-at-hotmail.com@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git