[FFmpeg-devel] Fix leak when user preallocates a AVFormatContext, passes it to av_open_input_file, but file does not exist on disk

Michael Niedermayer michaelni
Wed Jul 8 03:30:38 CEST 2009


On Tue, Jul 07, 2009 at 09:31:53PM +0100, M?ns Rullg?rd wrote:
> Art Clarke <aclarke at xuggle.com> writes:
> 
> > On Mon, Jul 6, 2009 at 8:05 AM, Art Clarke <aclarke at xuggle.com> wrote:
> >
> >>
> >> On Thu, Jul 2, 2009 at 2:47 PM, Art Clarke <aclarke at xuggle.com> wrote:
> >>
> >>> av_open_input_file takes memory ownership of *ic_ptr, and therefore must
> >>> free it if it nulls it.  If you pass in your own AVFormatContext (i.e. you
> >>> pass in AVFormatParameters with prealloced_context>0), but then the file
> >>> doesn't exist on disk, the current code nulls the AVFormatContext pointer
> >>> without freeing it (while if av_open_input_stream fails, it will free it
> >>> before nulling it).
> >>>
> >>> This patch makes the behavior consistent and patches a leak as a result.
> >>>
> >> Ping?
> >
> > Again (and last time; I'll assume rejected otherwise).
> >
> >
> > Index: libavformat/utils.c
> > ===================================================================
> > --- libavformat/utils.c	(revision 19327)
> > +++ libavformat/utils.c	(working copy)
> > @@ -499,6 +499,7 @@
> >      av_freep(&pd->buf);
> >      if (pb)
> >          url_fclose(pb);
> > +    av_free(*ic_ptr);
> >      *ic_ptr = NULL;
> >      return err;
> 
> av_freep(ic_ptr);

with that change iam ok with the patch ...

and sorry for the review delay ...

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090708/c6021f5a/attachment.pgp>



More information about the ffmpeg-devel mailing list