From patchwork Tue Aug 6 09:01:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13754593 Received: from fhigh3-smtp.messagingengine.com (fhigh3-smtp.messagingengine.com [103.168.172.154]) (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 B8C311BDAB8 for ; Tue, 6 Aug 2024 09:01:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722934883; cv=none; b=s5SMxJU19CdEVJA36VEVG1vse8eY8dkAvPmoxbfZ9RjiJ731fU5kMDrDppXNZID5zXL9tT6E1/0t8T0BpSWnWmO6lzt/xgl/XWQOGA+8R+mKLpgGdzCMiXFH2E2dzz7WGhLPSqEHLMDoTuqEVgbezE0v8j4ISWWtTzXz5lvePow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722934883; c=relaxed/simple; bh=ZclYzd3Xp/pucf7u+yZFATP6xc1Arw/qfGliChDq4hs=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GrL6uB0jhQqP8QD+gJhDefXCa+47fGpG33hxny8vlRXddoYrj1F5bihw1VXaMdbI46yPVlUmiK8qvG6nurh4H12kGY++TmuHjMcVmksRaVhJMp2ZMrfrVrkZ0aTOoadFRi75pyDsAvMw1A6ezJJXlmrsx83iB1m3KSMfspi6rlE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=NQGKRrYt; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=t+UIuJyj; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="NQGKRrYt"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="t+UIuJyj" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 1B3B2114FBD9 for ; Tue, 6 Aug 2024 05:01:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 06 Aug 2024 05:01:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1722934881; x=1723021281; bh=q+xAjQuWj0 /Loedc3EqR7JDNyoDS8duca2E+AAj1z5A=; b=NQGKRrYt7+M7W2cDev5/F4rx5E IYtilMItyYMaF9YhSdm1dVRfn8rRi2xkXcBoNnjlqPZQoL8rGro05bNubFjr41rU fYcEmIpQTNpTTJwA8Q330tcZZTANBNhNZAYl/ruOpbSK/EeC4W9etdoE3wXU0Osr 8+xLUwcV7Zvb888Xs+cVu2emMUsU9SSjUbhx4HmrFrIqEsPENac4qp9h90527e5c FwmKfU39FUn9F9edqeWB7/SHovKXfBt8Zl1tTF0Dg2dSrK4ED5DUh+nbWKrw/0ue wBSuU2stDgcCnt47fTWghL+lZu3a9WNObemC/9shRgrR/cCIGHoIaRFwYdEg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1722934881; x=1723021281; bh=q+xAjQuWj0/Loedc3EqR7JDNyoDS 8duca2E+AAj1z5A=; b=t+UIuJyjxfilvtcCFqNeRTxyNnbPgPK9dVGUaBNshwoJ wz0e0B0rMSrYzbcmtTbfgv7J7eJ8HEVOkWhAnL+mMpv8Uk1d7UOesbQ3tJygZ0CL 8fSjD0Q4TyzJESafjlQ1LA39dFcG1SvI5k9/DoLneWP46/jtBMkiZZ/xngURob+2 AIJSQFcN2G9Mt4JS5JqwG69OB8i67pzXaL3NR6bBrXQmbHo0Ebf3GYAGi/kjBrJl cvR7dKcrICyB0iTAfiocVnfWmkmOLMxAz6lCyXC8sUABpwpgF41oLILOJkTKZWUN pqmEUIQ7Cc0ccT+Nh311KYcXE0nL90IEjbe33+tKaw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrkeekgddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpeegnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 6 Aug 2024 05:01:20 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id f0362ebd (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 6 Aug 2024 09:01:18 +0000 (UTC) Date: Tue, 6 Aug 2024 11:01:18 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 22/22] builtin/diff: free symmetric diff members 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: We populate a `struct symdiff` in case the user has requested a symmetric diff. Part of this is to populate a `skip` bitmap that indicates whihc commits shall be ignored in the diff. But while this bitmap is dynamically allocated, we never free it. Fix this by introducing and calling a new `symdiff_release()` function that does this for us. Signed-off-by: Patrick Steinhardt --- builtin/diff.c | 10 +++++++++- t/t4068-diff-symmetric-merge-base.sh | 1 + t/t4108-apply-threeway.sh | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/builtin/diff.c b/builtin/diff.c index 9b6cdabe15..f87f68a5bc 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -388,6 +388,13 @@ static void symdiff_prepare(struct rev_info *rev, struct symdiff *sym) sym->skip = map; } +static void symdiff_release(struct symdiff *sdiff) +{ + if (!sdiff) + return; + bitmap_free(sdiff->skip); +} + int cmd_diff(int argc, const char **argv, const char *prefix) { int i; @@ -398,7 +405,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) struct object_array_entry *blob[2]; int nongit = 0, no_index = 0; int result; - struct symdiff sdiff; + struct symdiff sdiff = {0}; /* * We could get N tree-ish in the rev.pending_objects list. @@ -619,6 +626,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) refresh_index_quietly(); release_revisions(&rev); object_array_clear(&ent); + symdiff_release(&sdiff); UNLEAK(blob); return result; } diff --git a/t/t4068-diff-symmetric-merge-base.sh b/t/t4068-diff-symmetric-merge-base.sh index eff63c16b0..4d6565e728 100755 --- a/t/t4068-diff-symmetric-merge-base.sh +++ b/t/t4068-diff-symmetric-merge-base.sh @@ -5,6 +5,7 @@ test_description='behavior of diff with symmetric-diff setups and --merge-base' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # build these situations: diff --git a/t/t4108-apply-threeway.sh b/t/t4108-apply-threeway.sh index c558282bc0..3211e1e65f 100755 --- a/t/t4108-apply-threeway.sh +++ b/t/t4108-apply-threeway.sh @@ -5,6 +5,7 @@ test_description='git apply --3way' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh print_sanitized_conflicted_diff () {