Commit 5b91a48c authored by Steven Walters's avatar Steven Walters Committed by Fiona Glaser

Fix memory leak in lavf demuxer.

Leak only occurred with input files that have more than one video stream.
parent 50cae3cf
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment