From 21a6034d692c281b5be13a7913dc948468747537 Mon Sep 17 00:00:00 2001 From: Steven Walters Date: Sun, 9 Jan 2011 16:01:04 -0500 Subject: [PATCH] Fix memory leak in lavf demuxer. Leak only occurred with input files that have more than one video stream. --- input/lavf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/input/lavf.c b/input/lavf.c index 56bfa29c..45faec4b 100644 --- a/input/lavf.c +++ b/input/lavf.c @@ -39,6 +39,12 @@ typedef struct cli_pic_t *first_pic; } lavf_hnd_t; +#define x264_free_packet( pkt )\ +{\ + av_free_packet( pkt );\ + av_init_packet( pkt );\ +} + static int read_frame_internal( cli_pic_t *p_pic, lavf_hnd_t *h, int i_frame, video_info_t *info ) { if( h->first_pic && !info ) @@ -81,6 +87,9 @@ static int read_frame_internal( cli_pic_t *p_pic, lavf_hnd_t *h, int i_frame, vi if( avcodec_decode_video2( c, &frame, &finished, pkt ) < 0 ) x264_cli_log( "lavf", X264_LOG_WARNING, "video decoding failed on frame %d\n", h->next_frame ); } + /* if the packet successfully decoded but the data from it is not desired, free it */ + else if( ret >= 0 ) + x264_free_packet( pkt ); } while( !finished && ret >= 0 ); if( !finished ) @@ -203,8 +212,7 @@ static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame ) static int release_frame( cli_pic_t *pic, hnd_t handle ) { - av_free_packet( pic->opaque ); - av_init_packet( pic->opaque ); + x264_free_packet( pic->opaque ); return 0; } -- 2.47.3