From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id BBECA45ECF for ; Mon, 17 Apr 2023 11:28:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D7AD568BE2E; Mon, 17 Apr 2023 14:28:47 +0300 (EEST) Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1883268A78A for ; Mon, 17 Apr 2023 14:28:42 +0300 (EEST) Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-1878504c22aso16566005fac.8 for ; Mon, 17 Apr 2023 04:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681730920; x=1684322920; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+7KEUN1wTY8bDRCs/Gm915j3cy8jrZMKEilg8w5D+Kk=; b=ERgzSEBeU44Ist0LD3CnAMN+qPDBxAkO5vZi4A3eiRv8TblqWzUrV0pUMoyCLemV5F 5K1fcX4q5SBvM2eqCuMgUVJXceyA9b1l0Y7HDWE8W1f++cazm9ytdY1QwKT3PMZ+RtL2 68ge8SaOFRO4/QH1IK4uvO73h4Fum2664iW4o04NoI7B5wNeINVhnIEI13YPdeNYLcwN cwznkgwfO5qGsM+FeXKWCDMSRXiJvuAOIQIYq0iB/kwloHTF7gluMNmhDXmp/O+0ttEB SvW7a+5LkzH0EuZWNrzg4YN826Ti6GC0ZAALRHF4NEzR7BTXD35EPqQUJS3sfTNr6AGk 7rqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681730920; x=1684322920; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+7KEUN1wTY8bDRCs/Gm915j3cy8jrZMKEilg8w5D+Kk=; b=PfAAgzDK5Z96hhPogftmTmSgud9wu96V3Eoaru8JQc78M3WqUb9KRBgsXLF7SuaQOh W1zE2yZA2hNV+nS1WuaLaV/hE25XAUTiKqk1dJ6uZDnVphHHX8vBPK6OftdQfN+dcaHS pybeKigtpHv5H1BAeGbPOPvMNPyGlobMZKHuIZBDX8LgJBf2OSUy+IggnBQHQ14USZoO /CvV16mQSdxqavjit7sHRu/NicP9mW93YRv+7//+G265Gdcjbx8fixjl639sDtIW7qGM k3aorLbyncxI5VQk0GO/sF1PxKFidH+6Hc5/dboddwFne1DQk6eshWQwbWYHp3vNo9vJ bXLQ== X-Gm-Message-State: AAQBX9eXkaXPDTD+FOp0LE9zUBQ0AJ8KIwIC9BLRBthjfhbSC1WfJuE7 ao7vooK9SQWo1zaipVGaaAYl94iIJzo= X-Google-Smtp-Source: AKy350YUFg0zjsQtaYcR5ERyu8xjjlLSQ4b6L5NQ6dwzIEdb6wtKV1MENp+QzVBsiFY4Xt65be0C0A== X-Received: by 2002:a05:6871:89f:b0:187:af03:a07d with SMTP id r31-20020a056871089f00b00187af03a07dmr6914643oaq.15.1681730919655; Mon, 17 Apr 2023 04:28:39 -0700 (PDT) Received: from [192.168.0.15] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id s2-20020a05687087c200b001802d3e181fsm4422503oam.14.2023.04.17.04.28.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Apr 2023 04:28:39 -0700 (PDT) Message-ID: <4ed9d14d-70f7-0f52-e87e-7c6815e75194@gmail.com> Date: Mon, 17 Apr 2023 08:28:37 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20230416222518.21308-1-michael@niedermayer.cc> <9c9cb310-7c50-a400-4165-51468f5a9af5@gmail.com> <20230417112623.GI275832@pb2> From: James Almer In-Reply-To: <20230417112623.GI275832@pb2> Subject: Re: [FFmpeg-devel] [PATCH 1/5] avcodec/pcm_rechunk_bsf: unref packet before putting a new one in X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 4/17/2023 8:26 AM, Michael Niedermayer wrote: > On Sun, Apr 16, 2023 at 07:57:00PM -0300, James Almer wrote: >> On 4/16/2023 7:25 PM, Michael Niedermayer wrote: >>> Fixes: memleak >>> Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_BSF_PCM_RECHUNK_fuzzer-5562089618407424 >>> >>> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg >>> Signed-off-by: Michael Niedermayer >>> --- >>> libavcodec/pcm_rechunk_bsf.c | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/libavcodec/pcm_rechunk_bsf.c b/libavcodec/pcm_rechunk_bsf.c >>> index 108d9e90b99..3f43934fe9a 100644 >>> --- a/libavcodec/pcm_rechunk_bsf.c >>> +++ b/libavcodec/pcm_rechunk_bsf.c >>> @@ -153,6 +153,7 @@ static int rechunk_filter(AVBSFContext *ctx, AVPacket *pkt) >>> } >>> } >>> + av_packet_unref(s->in_pkt); >> >> This could be pointing to a bug in the above code, and unreffing here like >> this would result in data loss. >> >> Does the following change also fix the memleak? >> >>> diff --git a/libavcodec/pcm_rechunk_bsf.c b/libavcodec/pcm_rechunk_bsf.c >>> index 108d9e90b9..032f914916 100644 >>> --- a/libavcodec/pcm_rechunk_bsf.c >>> +++ b/libavcodec/pcm_rechunk_bsf.c >>> @@ -151,7 +151,8 @@ static int rechunk_filter(AVBSFContext *ctx, AVPacket *pkt) >>> av_packet_move_ref(pkt, s->in_pkt); >>> return send_packet(s, nb_samples, pkt); >>> } >>> - } >>> + } else >>> + av_packet_unref(s->in_pkt); >>> >>> ret = ff_bsf_get_packet_ref(ctx, s->in_pkt); >>> if (ret == AVERROR_EOF && s->out_pkt->size) { >> >> If it does then a zero sized packet with either only side data or that went >> through the av_packet_make_refcounted() in av_bsf_send_packet() that left it >> with an allocated padding buffer was fed to this bsf. > > yes this works too > and this memleak is open since a year, its the 2nd time i submited this Yes, i had a sense of deja vu. > patch, last time the discussions didnt lead to any consensus on what to do > I hope this time some fix from someone ends up in git > > thx Just apply the suggested change i made above. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".