Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
95a2966f
Unverified
Commit
95a2966f
authored
Jul 13, 2021
by
Edward Thomson
Committed by
GitHub
Jul 13, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5908 from punkymaniac/patch-mem-leak
Fix memory leak in git_smart__connect
parents
6be9e80e
bea1b024
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
src/transports/smart.c
+2
-0
tests/online/fetch.c
+40
-0
No files found.
src/transports/smart.c
View file @
95a2966f
...
@@ -226,6 +226,8 @@ static int git_smart__connect(
...
@@ -226,6 +226,8 @@ static int git_smart__connect(
t
->
url
=
git__strdup
(
url
);
t
->
url
=
git__strdup
(
url
);
GIT_ERROR_CHECK_ALLOC
(
t
->
url
);
GIT_ERROR_CHECK_ALLOC
(
t
->
url
);
git_proxy_options_clear
(
&
t
->
proxy
);
if
(
git_proxy_options_dup
(
&
t
->
proxy
,
proxy
)
<
0
)
if
(
git_proxy_options_dup
(
&
t
->
proxy
,
proxy
)
<
0
)
return
-
1
;
return
-
1
;
...
...
tests/online/fetch.c
View file @
95a2966f
...
@@ -3,9 +3,19 @@
...
@@ -3,9 +3,19 @@
static
git_repository
*
_repo
;
static
git_repository
*
_repo
;
static
int
counter
;
static
int
counter
;
static
char
*
_remote_proxy_scheme
=
NULL
;
static
char
*
_remote_proxy_host
=
NULL
;
static
char
*
_remote_proxy_user
=
NULL
;
static
char
*
_remote_proxy_pass
=
NULL
;
void
test_online_fetch__initialize
(
void
)
void
test_online_fetch__initialize
(
void
)
{
{
cl_git_pass
(
git_repository_init
(
&
_repo
,
"./fetch"
,
0
));
cl_git_pass
(
git_repository_init
(
&
_repo
,
"./fetch"
,
0
));
_remote_proxy_scheme
=
cl_getenv
(
"GITTEST_REMOTE_PROXY_SCHEME"
);
_remote_proxy_host
=
cl_getenv
(
"GITTEST_REMOTE_PROXY_HOST"
);
_remote_proxy_user
=
cl_getenv
(
"GITTEST_REMOTE_PROXY_USER"
);
_remote_proxy_pass
=
cl_getenv
(
"GITTEST_REMOTE_PROXY_PASS"
);
}
}
void
test_online_fetch__cleanup
(
void
)
void
test_online_fetch__cleanup
(
void
)
...
@@ -14,6 +24,11 @@ void test_online_fetch__cleanup(void)
...
@@ -14,6 +24,11 @@ void test_online_fetch__cleanup(void)
_repo
=
NULL
;
_repo
=
NULL
;
cl_fixture_cleanup
(
"./fetch"
);
cl_fixture_cleanup
(
"./fetch"
);
git__free
(
_remote_proxy_scheme
);
git__free
(
_remote_proxy_host
);
git__free
(
_remote_proxy_user
);
git__free
(
_remote_proxy_pass
);
}
}
static
int
update_tips
(
const
char
*
refname
,
const
git_oid
*
a
,
const
git_oid
*
b
,
void
*
data
)
static
int
update_tips
(
const
char
*
refname
,
const
git_oid
*
a
,
const
git_oid
*
b
,
void
*
data
)
...
@@ -207,3 +222,28 @@ void test_online_fetch__twice(void)
...
@@ -207,3 +222,28 @@ void test_online_fetch__twice(void)
git_remote_free
(
remote
);
git_remote_free
(
remote
);
}
}
void
test_online_fetch__proxy
(
void
)
{
git_remote
*
remote
;
git_buf
url
=
GIT_BUF_INIT
;
git_fetch_options
fetch_opts
;
if
(
!
_remote_proxy_host
||
!
_remote_proxy_user
||
!
_remote_proxy_pass
)
cl_skip
();
cl_git_pass
(
git_buf_printf
(
&
url
,
"%s://%s:%s@%s/"
,
_remote_proxy_scheme
?
_remote_proxy_scheme
:
"http"
,
_remote_proxy_user
,
_remote_proxy_pass
,
_remote_proxy_host
));
cl_git_pass
(
git_fetch_options_init
(
&
fetch_opts
,
GIT_FETCH_OPTIONS_VERSION
));
fetch_opts
.
proxy_opts
.
type
=
GIT_PROXY_SPECIFIED
;
fetch_opts
.
proxy_opts
.
url
=
url
.
ptr
;
cl_git_pass
(
git_remote_create
(
&
remote
,
_repo
,
"test"
,
"https://github.com/libgit2/TestGitRepository.git"
));
cl_git_pass
(
git_remote_connect
(
remote
,
GIT_DIRECTION_FETCH
,
NULL
,
&
fetch_opts
.
proxy_opts
,
NULL
));
cl_git_pass
(
git_remote_fetch
(
remote
,
NULL
,
&
fetch_opts
,
NULL
));
git_remote_free
(
remote
);
git_buf_dispose
(
&
url
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment