Skip to content

Commit 6b33894

Browse files
rscharfegitster
authored andcommitted
transport: simplify duplicating a substring in transport_get() using xmemdupz()
Signed-off-by: Rene Scharfe <l.s.r@web.de> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c2e8e4b commit 6b33894

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

transport.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -971,9 +971,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
971971
} else {
972972
/* Unknown protocol in URL. Pass to external handler. */
973973
int len = external_specification_len(url);
974-
char *handler = xmalloc(len + 1);
975-
handler[len] = 0;
976-
strncpy(handler, url, len);
974+
char *handler = xmemdupz(url, len);
977975
transport_helper_init(ret, handler);
978976
}
979977

0 commit comments

Comments
 (0)