[FFmpeg-devel] [PATCH] Fix leaking of side data.

Michael Niedermayer michaelni at gmx.at
Thu Jan 12 23:00:48 CET 2012


On Thu, Jan 12, 2012 at 09:43:13PM +0100, Reimar Döffinger wrote:
> While we correctly "register" the side data when we split it,
> the application (in this case FFmpeg) might not update the
> AVPacket pool it uses to finally free the packet, thus
> causing a leak.
> This also makes the av_dup_packet unnecessary which could
> cause an even worse leak in this situation.
[...]
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index b79e23e..83bab2d 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -988,7 +988,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
>          return -1;
>  
>      if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){
> -        av_packet_split_side_data(avpkt);
> +        int did_split = av_packet_split_side_data(avpkt);
>          apply_param_change(avctx, avpkt);
>          avctx->pkt = avpkt;
>          if (HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME)
> @@ -1015,6 +1015,8 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
>  
>          emms_c(); //needed to avoid an emms_c() call before every return;
>  
> +        if (did_split)
> +            ff_packet_free_side_data(avpkt);

I think this needs to update avpkt->size so the side data is not
totally lost

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120112/190c5617/attachment.asc>


More information about the ffmpeg-devel mailing list