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

[PATCH 1/5] receive-pack: don't copy "dir" parameter

From
Jeff King <peff@peff.net>
Date
Jul 24, 2014, 04:40 UTC
Message-ID
<20140724044042.GA32355@peff.net>
In-Reply-To
<20140724043940.GA31282@peff.net>

We used to do this so could pass a mutable string to enter_repo. But since 1c64b48 (enter_repo: do not modify input, 2011-10-04), this is not necessary.

The resulting code is simpler, and it fixes a minor leak.
Signed-off-by: Jeff King <peff@peff.net>
---
If you are wondering whether upload-pack needs the same treatment, we
already did it in 6379dd0.
 builtin/receive-pack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 92561bf..f93ac45 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1122,7 +1122,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 	int advertise_refs = 0;
 	int stateless_rpc = 0;
 	int i;
-	char *dir = NULL;
+	const char *dir = NULL;
 	struct command *commands;
 	struct sha1_array shallow = SHA1_ARRAY_INIT;
 	struct sha1_array ref = SHA1_ARRAY_INIT;
@@ -1157,7 +1157,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 		}
 		if (dir)
 			usage(receive_pack_usage);
-		dir = xstrdup(arg);
+		dir = arg;
 	}
 	if (!dir)
 		usage(receive_pack_usage);
-- 
2.0.0.566.gfe3e6b2
Previous: Jeff KingNext: Jeff King
Message 2 of 8 in “coverity mixed bag”
  1. 0/5 coverity mixed bagJeff King, Jul 24, 2014
  2. 1/5 receive-pack: don't copy "dir" parameterJeff King, Jul 24, 2014
  3. 2/5 free ref string returned by dwim_refJeff King, Jul 24, 2014
  4. 3/5 transport: fix leaks in refs_from_alternate_cbJeff King, Jul 24, 2014
  5. 4/5 fix memory leak parsing core.commentcharJeff King, Jul 24, 2014
  6. 5/5 apply: avoid possible bogus pointerJeff King, Jul 24, 2014
  7. Junio C HamanoJul 24, 2014
  8. Stefan BellerJul 29, 2014

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.