[FFmpeg-devel] One memory leakage in AAC/AC3 parser in ffmpeg

David LIU david.liu
Wed Jun 18 11:58:02 CEST 2008


Hi,

Please review patch and let me know reject or accept

Best regards

David Liu

Home Video Division

Tina: 041-4607 

-----Original Message-----
From: ffmpeg-devel-bounces at mplayerhq.hu
[mailto:ffmpeg-devel-bounces at mplayerhq.hu] On Behalf Of Stefano Sabatini
Sent: Thursday, June 12, 2008 2:34 PM
To: ffmpeg-devel at mplayerhq.hu
Subject: Re: [FFmpeg-devel] One memory leakage in AAC/AC3 parser in ffmpeg

On date Thursday 2008-06-12 13:26:18 +0200, David LIU encoded:
> Sorry, Miss the [FFmpeg-devel] in the mail title and just to add. 
> 
> -----Original Message-----
> From: david [mailto:david.liu at st.com]
> Sent: Thursday, June 12, 2008 10:36 AM
> To: 'ffmpeg-devel at mplayerhq.hu'
> Subject: One memory leakage in AAC/AC3 parser
> 
> Hi Ffmpeg developer,
> 
> I found there is one potential memory leakage in AAC/AC3 parser.
> 
> Here I have one stream (AVI stream which contains Divx and AC3) and use
ffmpeg to demux and decode.
> 
> What I found is that:
> 
> 1. ff_aac_ac3_parse() parse this audio stream. It will call
ff_combine_frame() to combine the truncated stream to a complete frame.
> 
> 2. In ff_combine_frame(), av_fast_realloc() will  re-allocate a new
memory.
> 
> 3. But there is no code to de-allocate this memory allocated by
ff_combine_frame() if I call av_parser_close().
> 
> So what I did is to
> 1. add ff_parse2_close() in ac3_parser.c like below:
> 
> AVCodecParser ac3_parser = {
>     { CODEC_ID_AC3 },
>     sizeof(AACAC3ParseContext),
>     ac3_parse_init,
>     ff_aac_ac3_parse,
>     // NULL, // david comment
> 	ff_parse2_close,
> };
> 
> 2. add ff_parse2_close() in parser.c like below:
> 
> void ff_parse2_close(AVCodecParserContext *s) // david added for ac3 and
aac {
>   AACAC3ParseContext *pc2 = s->priv_data; #undef printf
>     printf("ff_parse_close pc2 0x%x \n", pc2);
> 	printf("ff_parse_close pc2->pc 0x%x \n", &(pc2->pc));
> 	printf("ff_parse1_close pc2->pc.buffer 0x%x\n", pc2->pc.buffer);
//david
> #define printf	
>     av_free(pc2->pc.buffer);
> }	
> 
> After this modification, the memory allocated by ff_combine_frame() will
be sure to be freed. Do you think my modification is meaningful?

Please could you send a patch with your modifications, this should make
easier to review them:
http://ffmpeg.mplayerhq.hu/general.html#SEC25

(Also avoid top-posting.)

Thanks for your contribution, regards.
--
FFmpeg = Frightening Free MultiPurpose ExchanGer
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parser.h.patch
Type: application/octet-stream
Size: 407 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080618/eddfd4b6/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ac3_parser.c.patch
Type: application/octet-stream
Size: 309 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080618/eddfd4b6/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parser.c.patch
Type: application/octet-stream
Size: 535 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080618/eddfd4b6/attachment-0002.obj>



More information about the ffmpeg-devel mailing list