[FFmpeg-devel] [PATCH] libavcodec: v4l2m2m: make sure to unref avpkt

Jorge Ramirez-Ortiz jramirez at baylibre.com
Wed Jun 27 00:49:51 EEST 2018


On 06/26/2018 11:36 PM, Lukas Rusak wrote:
> This was found using valgrind. Using this patch there is no more memleak present.
> ---
>   libavcodec/v4l2_m2m_dec.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> index 598dc10781..710e40efd8 100644
> --- a/libavcodec/v4l2_m2m_dec.c
> +++ b/libavcodec/v4l2_m2m_dec.c
> @@ -149,11 +149,14 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame)
>   
>       if (avpkt.size) {
>           ret = v4l2_try_start(avctx);
> -        if (ret)
> +        if (ret) {
> +            av_packet_unref(&avpkt);
>               return 0;
> +        }
>       }
>   
>   dequeue:
> +    av_packet_unref(&avpkt);
>       return ff_v4l2_context_dequeue_frame(capture, frame);
>   }
>   

ack'd and tested



More information about the ffmpeg-devel mailing list