Thread (8 messages) 8 messages, 1 author, 2025-06-18
STALE365d
Revisions (4)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v3 current
  4. v4 [diff vs current]

[PATCH v3 2/7] remote: fix tear down of struct remote

From: Jacob Keller <jacob.e.keller@intel.com>
Date: 2025-06-18 23:08:34
Subsystem: the rest · Maintainer: Linus Torvalds

From: Jacob Keller <redacted>

The remote_clear() function failed to free the remote->push and
remote->fetch refspec fields.

This should be caught by the leak sanitizer. However, for callers which
use ``the_repository``, the values never go out of scope and the
sanitizer doesn't complain.

A future change is going to add a caller of read_config() for a
submodule repository structure, which would result in the leak sanitizer
complaining.

Fix remote_clear(), updating it to properly call refspec_clear() for
both the push and fetch members.

Signed-off-by: Jacob Keller <redacted>
---
 remote.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/remote.c b/remote.c
index dff76e4626cc4eea54a28a63acc43aea2115cf56..e6f0721060a1ad6b119e5e45545c8c6ca94658af 100644
--- a/remote.c
+++ b/remote.c
@@ -165,6 +165,9 @@ static void remote_clear(struct remote *remote)
 	strvec_clear(&remote->url);
 	strvec_clear(&remote->pushurl);
 
+	refspec_clear(&remote->push);
+	refspec_clear(&remote->fetch);
+
 	free((char *)remote->receivepack);
 	free((char *)remote->uploadpack);
 	FREE_AND_NULL(remote->http_proxy);
-- 
2.48.1.397.gec9d649cc640
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help