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

[PATCH] drop unnecessary copying in credential_ask_one

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Jan 2, 2014, 01:06 UTC
Message-ID
<1388624793-5563-1-git-send-email-rctay89@gmail.com>

We were leaking memory in there, as after obtaining a string from git_getpass, we returned a copy of it, yet no one else held the original string, apart from credential_ask_one.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 credential.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/credential.c b/credential.c
index 86397f3..0d02ad8 100644
--- a/credential.c
+++ b/credential.c
@@ -54,7 +54,7 @@ static char *credential_ask_one(const char *what, struct credential *c)
 
 	strbuf_release(&desc);
 	strbuf_release(&prompt);
-	return xstrdup(r);
+	return r;
 }
 
 static void credential_getpass(struct credential *c)
-- 
1.8.5-rc2
Next: Jeff King
Message 1 of 7 in “drop unnecessary copying in credential_ask_one”
  1. drop unnecessary copying in credential_ask_oneTay Ray Chuan, Jan 2, 2014
  2. Jeff KingJan 2, 2014
  3. Jeff KingJan 2, 2014
  4. Junio C HamanoJan 2, 2014
  5. Jeff KingJan 7, 2014
  6. Junio C HamanoJan 7, 2014
  7. Jeff KingJan 7, 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.