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

[PATCH] transport: simplify duplicating a substring in transport_get() using xmemdupz()

From
René Scharfe <l.s.r@web.de>
Date
Dec 24, 2014, 00:18 UTC
Message-ID
<549A0657.6010509@web.de>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 transport.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/transport.c b/transport.c
index 70d38e4..08bcd3a 100644
--- a/transport.c
+++ b/transport.c
@@ -971,9 +971,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
 	} else {
 		/* Unknown protocol in URL. Pass to external handler. */
 		int len = external_specification_len(url);
-		char *handler = xmalloc(len + 1);
-		handler[len] = 0;
-		strncpy(handler, url, len);
+		char *handler = xmemdupz(url, len);
 		transport_helper_init(ret, handler);
 	}
 
-- 
2.2.1
Next: Jonathan Nieder
Message 1 of 2 in “transport: simplify duplicating a substring in transport_get() using xmemdupz()”
  1. transport: simplify duplicating a substring in transport_get() using xmemdupz()René Scharfe, Dec 24, 2014
  2. Jonathan NiederDec 24, 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.