From patchwork Sun Jul 7 18:47:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 50392 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp5406044vqv; Sun, 7 Jul 2024 11:48:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXApx/e4nAVWzQlREamLo2kSB6A0OqmV5BKUxLHKJ7tYO5BFsKXSMszWNUExCEQXgNN/2c/rhLil7H66y/235VaWvmdlamireBFmw== X-Google-Smtp-Source: AGHT+IEg4AtsFhjvkgmHQKdZlSyUJKyYF21oTCrGlRKHRzIJgD5Ll7p5zOntxGaCKAwaM30inOiI X-Received: by 2002:a05:6512:3282:b0:52c:850b:cfc6 with SMTP id 2adb3069b0e04-52ea0640028mr6373752e87.38.1720378093760; Sun, 07 Jul 2024 11:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720378093; cv=none; d=google.com; s=arc-20160816; b=cBxYghr8qzw0NThfWLmovVMVQVM7kyfRsNIO7RmUGMBwQO0CyXaZ9I0ekEPEfs53JO pPKuwik2hH2D5ieLbMhbPxrVLnJRRKgKi44rawlH1q5efpIhq/OLwe85MeYkMqe+0fn+ ppAG/DN8/uoM8Sn7CVG9Z3joIhmJKAPqj8Y0gMNfmGzSgwAu9mASjaOcZTKJC5ZXs0TI 8jX0P+SOrAJefMt+Xp0d03lcWKXqEjzz33+j5fhJpnbDDKPFMBLuIyx2rHCoukgbIWYN GsPZIncZF0lUZGG6K3H3RXTbMIPM9Zfn9flEXgoU8giC248hMfYtkroj0WeJJtNZgvbH qhCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=IDvzcJ+ziR9+qDUvVHSg822OMRu2jVGDDZA/z4roWvk=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=MRJN7GkeCiF+ohcDFgi9FIRDeCHUGJ9wAU57wjPHITfgBS5csBwZfNMp84XIB/cv3B 6ICOrc7mbCCZjtMesMt9gPG4jodkZOSM2KYmHYtpJZBz/+ufV986bPYouQpPFz+hm4bH RwMp7rvkqthr2lrE5iW50R95PjehFaHhQFJwyQuUkG2350DEKeRVM5ZEIXIs+VZaQ7X3 s8N27d0QsiwqZ2D++mMI/ezWmvu1v6m4+/nKGGk6rdm6zufihXIDTqwu51lNw8Gnmwsk 2wnAzHgPbCelyPnBHT0VI48xj2Ntxi/CWpoVcCOHlhllsvdXNJx+MsXRRSI7uqI6y+XZ 51EQ==; 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=SCiZuG8b; 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 2adb3069b0e04-52ea2136f07si2315701e87.336.2024.07.07.11.48.13; Sun, 07 Jul 2024 11:48:13 -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=SCiZuG8b; 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 DAB2D68DB56; Sun, 7 Jul 2024 21:47:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8DBCA68DA48 for ; Sun, 7 Jul 2024 21:47:33 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id F2D08240005 for ; Sun, 7 Jul 2024 18:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1720378053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xRzPURJXKcNumGb6Ruw5Jpb/aCJq7U/Ou4pDJX8TYWA=; b=SCiZuG8bYViZaQwp41It3yTKnObLDshITn1e9aulm1XEWMLyNTOLrGocZiBtxPMI5RbJuO BTOXQN1bvAVk8kwDIG+tyNILv6z/sAJgDCimuxGhx4cc1drPB7YbXwKfQAxaN5GQeRggrI dmN0MoLp6Z/v0YaDawYD4ehhEbZBkXg+Rzs1AoIWbr6tFvzuk3FJhcMtCwP3DbHc9b9mOG gmp1R9GmGrAd+aGOVNTMLYVStkxWvEJWcbu1scN4qXylcf6ySRKxlUheJCoM5YPASx67qT re0cqTMVLVXhzr0XprdsyH4BuQHaCrW1Rho/lciH0PH3V7WnkX+opOSINjti9g== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 7 Jul 2024 20:47:27 +0200 Message-ID: <20240707184729.3525852-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240707184729.3525852-1-michael@niedermayer.cc> References: <20240707184729.3525852-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 4/6] avdevice/dshow_capture: Fix error handling in ff_dshow_##prefix##_Create() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: TIL7LTVYaV/+ Untested, needs review Fixes: CID1591856 Resource leak Fixes: CID1591887 Resource leak Fixes: CID1591874 Resource leak Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavdevice/dshow_capture.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index 81e684b9be3..bb39d4947aa 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -124,14 +124,15 @@ void ff_dshow_##prefix##_Destroy(class *this) \ class *ff_dshow_##prefix##_Create(__VA_ARGS__) \ { \ class *this = CoTaskMemAlloc(sizeof(class)); \ - void *vtbl = CoTaskMemAlloc(sizeof(*this->vtbl)); \ dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_Create(%p)\n", this); \ - if (!this || !vtbl) \ + if (!this) \ goto fail; \ ZeroMemory(this, sizeof(class)); \ - ZeroMemory(vtbl, sizeof(*this->vtbl)); \ + this->vtbl = CoTaskMemAlloc(sizeof(*this->vtbl)); \ + if (!this->vtbl) \ + goto fail; \ + ZeroMemory(this->vtbl, sizeof(*this->vtbl)); \ this->ref = 1; \ - this->vtbl = vtbl; \ if (!setup) \ goto fail; \ dshowdebug("created ff_dshow_"AV_STRINGIFY(prefix)" %p\n", this); \