git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] clone: use free_refspec() to free refspec list

From
Jeff King <peff@peff.net>
Date
May 15, 2017, 07:50 UTC
Message-ID
<20170515075011.5pm6j3k3fwentm2o@sigill.intra.peff.net>
In-Reply-To
<20170515074617.wsdzogshc4ilnlsb@sigill.intra.peff.net>

Using free() on a refspec was always leaky, as its string fields also need freed. But it became more so when ad00f128d (clone: respect configured fetch respecs during initial fetch, 2016-03-30) taught clone to create a list of refspecs, each of which need to be freed.

Signed-off-by: Jeff King <peff@peff.net>
---
It's doubtful anyone cares, as this is right before program exit anyway.
But if we're going to bother to free(), we may as well do it right.
 builtin/clone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 645cfa4fd..672c5b0a6 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -1144,6 +1144,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	strbuf_release(&value);
 	junk_mode = JUNK_LEAVE_ALL;
 
-	free(refspec);
+	free_refspec(refspec_count, refspec);
 	return err;
 }
-- 
2.13.0.458.g025404205
Previous: Jeff King
Message 4 of 4 in “cleanups on top of sg/clone-refspec-from-command-line-config”
  1. 0/3 cleanups on top of sg/clone-refspec-from-command-line-configJeff King, May 15, 2017
  2. 1/3 clone: factor out refspec parsingJeff King, May 15, 2017
  3. 2/3 remote: drop free_refspecs() functionJeff King, May 15, 2017
  4. 3/3 clone: use free_refspec() to free refspec listJeff King, May 15, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.