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

Mark Thompson sw at jkqxz.net
Mon May 5 19:34:39 EEST 2025


On 03/05/2025 23:46, James Almer wrote:
> 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;
> 
Set applied with this change and always using explicit memory ordering.

Thanks,

- Mark



More information about the ffmpeg-devel mailing list