diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c index 912c707a68..4d8bf4fe71 100644 --- a/libavcodec/hw_base_encode.c +++ b/libavcodec/hw_base_encode.c @@ -804,10 +804,10 @@ int ff_hw_base_encode_init(AVCodecContext *avctx, FFHWBaseEncodeContext *ctx) int ff_hw_base_encode_close(FFHWBaseEncodeContext *ctx) { - FFHWBaseEncodePicture *pic; - - for (pic = ctx->pic_start; pic; pic = pic->next) + for (FFHWBaseEncodePicture *pic = ctx->pic_start, *next_pic = pic; pic; pic = next_pic) { + next_pic = pic->next; base_encode_pic_free(pic); + } av_fifo_freep2(&ctx->encode_fifo);