[FFmpeg-devel] Fix leak when user preallocates a AVFormatContext, passes it to av_open_input_file, but file does not exist on disk
Måns Rullgård
mans
Tue Jul 7 22:31:53 CEST 2009
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);
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list