From patchwork Mon Apr 1 20:56:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 47705 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9f96:b0:1a3:b6bb:3029 with SMTP id mm22csp979451pzb; Mon, 1 Apr 2024 13:56:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUzMpXcIuUuvd61klnYpLEJdmuw55dj55kNvCMFFQ0zzqgdjnPljaYPHyHlTWk8kIZcss9Q9lXmoBbaRgYi/bNWnwCp7vhcqRtYyA== X-Google-Smtp-Source: AGHT+IFEh6hQIryj17zvY+RW7FddaF+Juisoyaf0VVCbCxoL4Q42xQox8UinOPJYu8/1ygxFIqOx X-Received: by 2002:a19:e01e:0:b0:515:cc50:9376 with SMTP id x30-20020a19e01e000000b00515cc509376mr7127543lfg.22.1712005004637; Mon, 01 Apr 2024 13:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712005004; cv=none; d=google.com; s=arc-20160816; b=Qxus5mjc+0onB41hgrL8+bSDqH4h2JBF/yICj6ocXnt6gL8bZeRJTCZRP2JxISh2hn t6h3NTcHHeUBrRUMVZtq1B0rDXIPJyrpaFFxCr+mRi/Vt5slvMjBk3y9EyVI45wFhk9K JZkwstIr6WGTThyIjIrZaYh8IhQLqpHwjw1IWQn94NeBfF5j+YH2VYJPfSY2msxAp6q6 NBO4NZpU5lRz+0YgQOSlo4Fd0WTJLUFs3yTLASzYclOzlJfLBXOTtCPPOGKU1gB4IjtV K4A9PkZeKWTv3oD0boLBFeqKrmRlfJrDElkOLLqa+Ia3HveubR+8CRpkUStEhLd/NFyI UWUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=gMhX5VEYXdttsPJne39YuHRNSpm/W3sy1lksspAZ84U=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=h7LfjRKjYGyQDfwcI3Er3rvk1/z41ib3odUZX78ABNkxsWyfjsZKDSmxeak9jEFJbs 0k/EAQLmBirzbdF0DKNnN22JqMlXbHY4Um+onnOyxhq/dRrRYn5oVPsir1EIURaKuZTt 4+UwQ72pbh9CpxnkF79tCfGk7dEHJ5rxyI+JGQiyF0MgpRtE011wLpFkuzn/PRKRM3/i JHRsyD05p2AD85Iaak+lL0TLHd6znI/d/gcS7r06qKR1s3kzPFWkfEJSHV8lgNXv2RN0 TNbChzKmfYY7q8Zsa42yMJ8ZXaRis/WYtn3C7mpxKZoMRD6sbbG+AylB8QLQklJf+pw6 6eMQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=OFbow7gE; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sh37-20020a1709076ea500b00a4e23493aa6si4853593ejc.94.2024.04.01.13.56.44; Mon, 01 Apr 2024 13:56:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=OFbow7gE; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C1E1F68CFD1; Mon, 1 Apr 2024 23:56:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AFDD668CF98 for ; Mon, 1 Apr 2024 23:56:11 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 07C9540004 for ; Mon, 1 Apr 2024 20:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1712004971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:in-reply-to:in-reply-to:references:references; bh=PRjK5KTNOWTbA0X0Hk0Wbh/XY4Q65AlWkL8sU0e8TTw=; b=OFbow7gE0w0HvR7vF8zgT3VBAx5Ueu7N2ekBOL24ItV8YbMFOR7lbtmhRjGRyx9AEcZvAY 3z2RkLxpo2foeXe5oxmWvuO8YZp0chrxqthVTC1c70lH72RH1PXyTCH5UDH3pwHMuXWa0h CKRiiAJ4CAbIXgh9UfWMb10Ea2VqokiYPt/miuUJ0OCwOVi8kptu/+OKyDAEb2RM5jA3oW 66hi4nOL/taerR0X5fCAU9MGpvWfXULJLQeDY3+tjADAXpSpeVmU+AOjCT5nf+zqT73QFK 1t9y3Oq4YI5AtykoNUWqCZMt0FeRa1iDshBLYleqd/HvqgZKgjjTycfpl1GPFg== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 1 Apr 2024 22:56:05 +0200 Message-Id: <20240401205607.9093-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240401205607.9093-1-michael@niedermayer.cc> References: <20240401205607.9093-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 4/6] avformat/demux_utils: Avoid leaking the packet in ff_add_attached_pic() 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: k1CmjlS+kMuC Fixes: memleak Fixes: 67714/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5671570999476224 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/demux_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/demux_utils.c b/libavformat/demux_utils.c index 86f551245be..96e6e20d1ec 100644 --- a/libavformat/demux_utils.c +++ b/libavformat/demux_utils.c @@ -123,9 +123,9 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st0, AVIOContext *pb, if (!st && !(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); pkt = &st->attached_pic; + av_packet_unref(pkt); if (buf) { av_assert1(*buf); - av_packet_unref(pkt); pkt->buf = *buf; pkt->data = (*buf)->data; pkt->size = (*buf)->size - AV_INPUT_BUFFER_PADDING_SIZE;