[FFmpeg-devel] [PATCH] remove memory leak from tools/pktdumper.c

Michael Niedermayer michaelni
Thu Apr 30 12:09:52 CEST 2009


On Thu, Apr 30, 2009 at 11:44:49AM +0200, Zdenek Kabelac wrote:
> Hi
> 
> This small patch should adapt probably not often used
> tools/pktdumper.c application to use newer packet reading API.
> (So machines with small memory should be able to dump even very large streams)
> 
> It should fix these valgrind errors:
> 
> ==4997== 21,528 bytes in 1 blocks are indirectly lost in loss record 1 of 4
> ==4997==    at 0x4C2576F: realloc (vg_replace_malloc.c:429)
> ==4997==    by 0x483138: av_fast_realloc (utils.c:76)
> ==4997==    by 0x40778C: av_add_index_entry.clone.4 (utils.c:1172)
> ==4997==    by 0x40ABFC: av_read_frame_internal (utils.c:931)
> ==4997==    by 0x4039AB: main (pktdumper.c:100)
> ==4997==
> ==4997==
> ==4997== 36,648 bytes in 7 blocks are indirectly lost in loss record 2 of 4
> ==4997==    at 0x4C23260: memalign (vg_replace_malloc.c:460)
> ==4997==    by 0x4C23317: posix_memalign (vg_replace_malloc.c:569)
> ==4997==    by 0x8BECA7: av_malloc (mem.c:66)
> ==4997==    by 0x40D58C: url_open_protocol (avio.c:76)
> ==4997==    by 0x40D748: url_open (avio.c:136)
> ==4997==    by 0x40EB00: url_fopen (aviobuf.c:603)
> ==4997==    by 0x409108: av_open_input_file (utils.c:449)
> ==4997==    by 0x40383F: main (pktdumper.c:86)
> ==4997==
> ==4997==
> ==4997== 125,256 (67,080 direct, 58,176 indirect) bytes in 130 blocks
> are definitely lost in loss record 3 of 4
> ==4997==    at 0x4C23260: memalign (vg_replace_malloc.c:460)
> ==4997==    by 0x4C23317: posix_memalign (vg_replace_malloc.c:569)
> ==4997==    by 0x8BECA7: av_malloc (mem.c:66)
> ==4997==    by 0x47A227: avformat_alloc_context (options.c:80)
> ==4997==    by 0x4072A4: av_open_input_stream (utils.c:364)
> ==4997==    by 0x409294: av_open_input_file (utils.c:489)
> ==4997==    by 0x40383F: main (pktdumper.c:86)
> ==4997==
> 
> 
> --------
> 
> Index: tools/pktdumper.c
> ===================================================================
> --- tools/pktdumper.c   (revision 18717)
> +++ tools/pktdumper.c   (working copy)
> @@ -95,8 +95,6 @@
>          return 1;
>      }
> 
> -    av_init_packet(&pkt);
> -

unrelated change


>      while ((err = av_read_frame(fctx, &pkt)) >= 0) {
>          int fd;
>          snprintf(pktfilename, PATH_MAX-1, fntemplate, pktnum,
> pkt.stream_index, pkt.pts, pkt.size, (pkt.flags &
> PKT_FLAG_KEY)?'K':'_');

this patch is mangled

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090430/587cb658/attachment.pgp>



More information about the ffmpeg-devel mailing list