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 <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2e8e4b commit 6b33894

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

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)