[FFmpeg-devel] One memory leakage in AAC/AC3 parser in ffmpeg
Stefano Sabatini
stefano.sabatini-lala
Thu Jun 12 14:33:51 CEST 2008
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
More information about the ffmpeg-devel
mailing list