[FFmpeg-devel] [PATCH 2/6] apv_decode: Fix memory leak on decode error

James Almer jamrial at gmail.com
Sun May 4 01:46:34 EEST 2025


On 5/3/2025 2:55 PM, Mark Thompson wrote:
> ---
>   libavcodec/apv_decode.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/apv_decode.c b/libavcodec/apv_decode.c
> index b1e1db7d64..2a59c9b25d 100644
> --- a/libavcodec/apv_decode.c
> +++ b/libavcodec/apv_decode.c
> @@ -377,7 +377,7 @@ static int apv_decode_frame(AVCodecContext *avctx, AVFrame *frame,
>           case APV_PBU_PRIMARY_FRAME:
>               err = apv_decode(avctx, frame, pbu->content);
>               if (err < 0)
> -                return err;
> +                goto fail;
>               *got_frame = 1;
>               break;
>           case APV_PBU_METADATA:
> @@ -412,8 +412,11 @@ static int apv_decode_frame(AVCodecContext *avctx, AVFrame *frame,
>       }
>   
>       ff_cbs_fragment_reset(au);
> -
>       return packet->size;
> +
> +fail:
> +    ff_cbs_fragment_reset(au);
> +    return err;
>   }
>   
>   const FFCodec ff_apv_decoder = {

nit: could instead make it

     err = packet->size;
fail:
     ff_cbs_fragment_reset(au);
     return err;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250503/ff9ace20/attachment.sig>


More information about the ffmpeg-devel mailing list