[FFmpeg-devel] One memory leakage in Mov parser
David LIU
david.liu
Wed Jun 18 09:30:51 CEST 2008
Hi All,
There is memory leakage during Mov reading head. In mov_read_trak() in libavformat/mov.c,
static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
{
...
sc = av_mallocz(sizeof(MOVStreamContext)); <- not freed later
...
}
What I fix is in
static int mov_read_close(AVFormatContext *s)
{
...
av_freep(&sc); //david added to fix memory leakage
...
}
I attached my mov.c here.
Best regards
David Liu
Home Video Division
Tina: 041-4607
-----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?
Best regards
David Liu
Home Video Division
Tina: 041-4607
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mov.c
Type: application/octet-stream
Size: 66244 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080618/731f1e87/attachment.obj>
More information about the ffmpeg-devel
mailing list