[FFmpeg-devel] [PATCH] Use av_mallocz in url_open_protocol for URLContext

Benoit Fouet benoit.fouet
Thu Jan 28 10:11:47 CET 2010


On Wed, 27 Jan 2010 19:46:29 +0100 Michael Niedermayer wrote:
> On Tue, Jan 26, 2010 at 06:32:27PM -0500, Daniel Kristjansson wrote:
> > If you register a protocol which uses private data then
> > av_open_protocol's url_seek() to determine whether the protocol
> > supports streaming will be called with uninitialized private data.
> > If say you use the private data in your custom seek bad things
> > happen. By using av_mallocz the priv_data is initialized to zero
> > and you can return -1 with the errno set until you can initialize
> > the priv_data after the av_open_protocol() call (and initialize
> > is_streamed as well if applicable).
> > 
> > The other way to handle this by creating your own URLContext
> > without a registered protocol is error prone. As an alternative
> > to av_mallocz, av_open_protocol() could just initialize priv_data
> > to NULL as it does other parts of the structure, if that is
> > preferred I can make a patch for that.
> > 
> > -- Daniel
> 
> >  avio.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 913b394072395cc6cdb4954e088de2639043d285  avio-mallocz.patch
> 
> ok
> 
> [...]

applied

Ben



More information about the ffmpeg-devel mailing list