[MPlayer-dev-eng] memory leak because of missing demux_close_asf()
Burkhard Fischer
b.fi2 at web.de
Sun Aug 20 13:35:56 CEST 2006
Hi,
I discovered a memory leak with ASF file format when running in loop mode.
valgrind gave some hints that in asf_check_header the allocated "struct
asf_priv* asf" is not freed.
Here is my patch (MPlayer-1.0pre8):
diff -Nau libmpdemux/asfheader.c /tmp/libmpdemux/asfheader.c
--- libmpdemux/asfheader.c 2006-06-11 20:35:46.000000000 +0200
+++ /tmp/libmpdemux/asfheader.c 2006-08-20 13:11:41.000000000 +0200
@@ -230,6 +230,8 @@
goto err_out;
}
+ // bf
+ pos=0;
if ((pos = find_asf_guid(hdr, asf_ext_stream_audio, pos, hdr_len)) >= 0)
{
// Special case: found GUID for dvr-ms audio.
diff -Nau libmpdemux/demux_asf.c /tmp/libmpdemux/demux_asf.c
--- libmpdemux/demux_asf.c 2006-06-11 20:35:46.000000000 +0200
+++ /tmp/libmpdemux/demux_asf.c 2006-08-20 13:11:41.000000000 +0200
@@ -255,7 +255,6 @@
stream_read(demux->stream,asf->packet,asf->packetsize);
if(demux->stream->eof) return 0; // EOF
-
{
unsigned char* p=asf->packet;
unsigned char* p_end=asf->packet+asf->packetsize;
@@ -544,8 +543,11 @@
//---- ASF header:
if(!asf) return NULL;
if (!read_asf_header(demuxer,asf)) {
- free(asf);
- return NULL;
+ // bf
+ if (asf->packet)
+ free(asf->packet);
+ free(asf);
+ return NULL;
}
stream_reset(demuxer->stream);
stream_seek(demuxer->stream,demuxer->movi_start);
@@ -578,6 +580,16 @@
}
+// bf
+void demux_close_asf(demuxer_t* demuxer) {
+ struct asf_priv* asf = demuxer->priv;
+
+ if(!asf) return NULL;
+ if (asf->packet)
+ free(asf->packet);
+ free(asf);
+}
+
demuxer_desc_t demuxer_desc_asf = {
"ASF demuxer",
"asf",
@@ -589,7 +601,9 @@
asf_check_header,
demux_asf_fill_buffer,
demux_open_asf,
- NULL, //demux_close_asf,
+ // bf
+ //NULL, //demux_close_asf,
+ demux_close_asf,
demux_seek_asf,
demux_asf_control
};
Another memory related problem seems to be when a file contains only the
beginning of MPEG-PS file (e.g. the splitted off beginning of a VOB
file). When this is played in a loop the mpeg2_malloc´s in
mpeg2_header_picture_finalize() seem to be the reasons for sometimes
quite huge memory leaks, detected by valgrind.
It there a way to handle this?
Thanks,
Burkhard
More information about the MPlayer-dev-eng
mailing list