transport: simplify duplicating a substring in transport_get() using xmemdupz()
PATCH 1/1 transport: simplify duplicating a substring in transport_get() using xmemdupz()
Signed-off-by Rene Scharfe <[email protected]>
--- transport.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
transport.c +1 -3
@@ -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); }
Signature · 1 line
2.2.1
Quoted 4 lines · René Scharfe
Signed-off-by Rene Scharfe <[email protected]>--- transport.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Since external_specification_len(url) is defined to always be less than strlen(url) when is_url(url), this should be safe.
Reviewed-by Jonathan Nieder <[email protected]>