From patchwork Tue Oct 24 13:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13434438 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13D4D2AB34 for ; Tue, 24 Oct 2023 13:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="ep0nTznG"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Hlf1vd0k" Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5737CC for ; Tue, 24 Oct 2023 06:10:52 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 165523200A22; Tue, 24 Oct 2023 09:10:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 24 Oct 2023 09:10:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1698153051; x=1698239451; bh=VT enEgeHwZu7nfoC1A+Tfn0b5SAeBiTRnXl01bRmPVY=; b=ep0nTznGH5ATQRjTt1 FwwlAS8iTuGmBFk3tXApRiRQhXVPfSnD7ECCGrCGUkTK0ho+R/DNSY6m4qgf9Kr1 Kq9aTCWFbPur7uArxB6/gCe+zk6IpGXIwDt99b7tuZcAREDhZIBS1WqX3S5x6Gmp 79NufUZz2OK7fvXFmuEMim8OXTpLpXcCqKmWnoLUx6+T9bEmF/duexCT9h/gEYdf jzoURZ5W2X+MLCC3GJ+vW6Xc3CrROrKAAMZWak/H1mxYcGuTqc7rvGwnXf5LEw3j VRCAhNZgf6qhc0DDjZ5yN2ABYJ8I9e9dDRFoL+VXqKhuPpJ3+aFid3pbLqwTe08x aroQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1698153051; x=1698239451; bh=VTenEgeHwZu7n foC1A+Tfn0b5SAeBiTRnXl01bRmPVY=; b=Hlf1vd0kpj298dFcWp1nhkVpaMk6n JfqJtl3Hup142yOF6FP1n6x2tWYX0vPVSuBbP5SQsMuOwwoWHJvHurY0AZKzIEaZ FnDddaoEk00P8fgWVGHeTzNfED7KEhq1uSUJiaf2/lRKfY+Y3daCanbDy45jlJbX sog8GMHW8C3nxEG1DKdGzN6zmV4+tLUMYMvIFYKmDunuuv7bTSVeOdKiSx3GKirs oPUmsZUC/gTIqK5C4hfj/uE94kwPDGkw9gixQI0C9hwq3oJWLZz9kb9IR6/k3wG+ cuOHBowoM8s8DvfOX3j6pk5FPGdqia2Ld6ADpSJhUV321pJMac0onLswA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrkeekgdeitdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleffteen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesph hkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Oct 2023 09:10:50 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id d9ea4d88 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 24 Oct 2023 13:10:45 +0000 (UTC) Date: Tue, 24 Oct 2023 15:10:48 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Junio C Hamano , Eric Sunshine , Han-Wen Nienhuys Subject: [PATCH 03/12] builtin/show-ref: fix leaking string buffer Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Fix a leaking string buffer in `git show-ref --exclude-existing`. While the buffer is technically not leaking because its variable is declared as static, there is no inherent reason why it should be. Signed-off-by: Patrick Steinhardt --- builtin/show-ref.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin/show-ref.c b/builtin/show-ref.c index 56ee3250c5f..761669d28de 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -106,7 +106,7 @@ static int add_existing(const char *refname, */ static int cmd_show_ref__exclude_existing(const char *match) { - static struct string_list existing_refs = STRING_LIST_INIT_DUP; + struct string_list existing_refs = STRING_LIST_INIT_DUP; char buf[1024]; int matchlen = match ? strlen(match) : 0; @@ -139,6 +139,8 @@ static int cmd_show_ref__exclude_existing(const char *match) printf("%s\n", buf); } } + + string_list_clear(&existing_refs, 0); return 0; }