Skip to content

Commit 2934b44

Browse files
committed
Fix memory leak in git_smart__connect
The call to git_proxy_options_dup will replace the url pointer of the proxy. But if the url pointer is already set, the old address will be lost forever and will never be free.
1 parent 868f4bc commit 2934b44

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/transports/smart.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ static int git_smart__connect(
226226
t->url = git__strdup(url);
227227
GIT_ERROR_CHECK_ALLOC(t->url);
228228

229+
if (t->proxy.url)
230+
git_proxy_options_clear(&t->proxy);
231+
229232
if (git_proxy_options_dup(&t->proxy, proxy) < 0)
230233
return -1;
231234

0 commit comments

Comments
 (0)