smart subtransport: don't free the url when resetting the stream

We reset the stream in the RPC (HTTP) case constantly and then pass the url
field to the action method for the transport to perform their action.

A transport would thus get `NULL` for the url and if it does use it, it might
crash or at least return an error making it impossible for it to work.

The transports that come with libgit2 keep their own copy of the url and thus
this issue was not noticed.
This commit is contained in:
Carlos Martín Nieto
2018-12-14 15:48:14 +01:00
parent da8138b012
commit e4d48bf3bb

View File

@@ -46,9 +46,6 @@ GIT_INLINE(int) git_smart__reset_stream(transport_smart *t, bool close_subtransp
}
if (close_subtransport) {
git__free(t->url);
t->url = NULL;
if (t->wrapped->close(t->wrapped) < 0)
return -1;
}
@@ -223,6 +220,7 @@ static int git_smart__connect(
if (git_smart__reset_stream(t, true) < 0)
return -1;
git__free(t->url);
t->url = git__strdup(url);
GITERR_CHECK_ALLOC(t->url);