summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2018-12-14 15:48:14 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2018-12-14 15:48:14 +0100
commite4d48bf3bbf43eaaf6a2b28d5865d211198cf3d2 (patch)
tree76a23d1af32cb9a2a8fa00402d5f97fff9b0028a
parentda8138b01217824cf211fa491608a7b067cf8e43 (diff)
downloadlibgit2-cmn/reset-dont-free-url.tar.gz
smart subtransport: don't free the url when resetting the streamcmn/reset-dont-free-url
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.
-rw-r--r--src/transports/smart.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 9fcbdcf21..072cffdb5 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -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);