[FFmpeg-devel] [PATCH 2/2] Free allocated packet before returning from av_read_frame_internal.

Jai Menon jmenon86
Thu Jul 15 07:16:31 CEST 2010


On Thu, Jul 15, 2010 at 2:45 AM, Reimar D?ffinger
<Reimar.Doeffinger at gmx.de> wrote:
> On Thu, Jul 15, 2010 at 02:35:45AM +0530, Jai Menon wrote:
>> ---
>> ?libavformat/utils.c | ? ?1 +
>> ?1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index 6fa4dff..bbe6a64 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -1118,6 +1118,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?goto got_packet;
>> ? ? ? ? ? ? ? ? ? ? ?}
>> ? ? ? ? ? ? ? ? ?}
>> + ? ? ? ? ? ? ? ?av_free_packet(&cur_pkt);
>
> It is missing from the av_read_frame documentation, but from the read_packet for
> the formats:
> ? ? ? ? ? ? ? When returning an error, pkt must not have been allocated
> ? ? ? ? ? ? ? or must be freed before returning
>
> You really shouldn't touch cur_pkt when the function failed, it might not even have been
> fully/properly initialized.

In this case, the packet is allocated and data read properly, but
dv_produce_packet errors out. I guess then a free_packet call should
be made like attached?

-- 
Jai Menon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avidec.diff
Type: text/x-patch
Size: 488 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100715/78640db9/attachment.bin>



More information about the ffmpeg-devel mailing list