Skip to content

Commit 21e6a11

Browse files
authored
Merge pull request libgit2#4359 from libgit2/cmn/proxy-options-free
Plug some leaks in curl's proxy handling
2 parents 58deac7 + 25fdb3f commit 21e6a11

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/curl_stream.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ static int curls_set_proxy(git_stream *stream, const git_proxy_options *proxy_op
195195
CURLcode res;
196196
curl_stream *s = (curl_stream *) stream;
197197

198+
git_proxy_options_clear(&s->proxy);
198199
if ((error = git_proxy_options_dup(&s->proxy, proxy_opts)) < 0)
199200
return error;
200201

@@ -295,6 +296,8 @@ static void curls_free(git_stream *stream)
295296

296297
curls_close(stream);
297298
git_strarray_free(&s->cert_info_strings);
299+
git_proxy_options_clear(&s->proxy);
300+
git_cred_free(s->proxy_cred);
298301
git__free(s);
299302
}
300303

src/proxy.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src)
3131

3232
return 0;
3333
}
34+
35+
void git_proxy_options_clear(git_proxy_options *opts)
36+
{
37+
git__free((char *) opts->url);
38+
opts->url = NULL;
39+
}

src/proxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
#include "git2/proxy.h"
1313

1414
extern int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src);
15+
extern void git_proxy_options_clear(git_proxy_options *opts);
1516

1617
#endif

0 commit comments

Comments
 (0)