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
9cc0ba6b
Commit
9cc0ba6b
authored
May 02, 2017
by
Edward Thomson
Committed by
GitHub
May 02, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4226 from libgit2/ethomson/memleak
WIP: squash some memleaks
parents
13c1bf07
1dc89aab
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
16 deletions
+29
-16
src/branch.c
+6
-4
src/odb_loose.c
+6
-0
src/refs.c
+2
-2
src/remote.c
+8
-8
src/repository.c
+2
-1
src/signature.c
+4
-1
tests/object/lookup.c
+1
-0
No files found.
src/branch.c
View file @
9cc0ba6b
...
...
@@ -130,14 +130,16 @@ int git_branch_create_from_annotated(
static
int
branch_equals
(
git_repository
*
repo
,
const
char
*
path
,
void
*
payload
)
{
git_reference
*
branch
=
(
git_reference
*
)
payload
;
git_reference
*
head
;
int
equal
;
git_reference
*
head
=
NULL
;
int
equal
=
0
;
if
(
git_reference__read_head
(
&
head
,
repo
,
path
)
<
0
||
git_reference_type
(
head
)
!=
GIT_REF_SYMBOLIC
)
return
0
;
git_reference_type
(
head
)
!=
GIT_REF_SYMBOLIC
)
goto
done
;
equal
=
!
git__strcmp
(
head
->
target
.
symbolic
,
branch
->
name
);
done:
git_reference_free
(
head
);
return
equal
;
}
...
...
src/odb_loose.c
View file @
9cc0ba6b
...
...
@@ -205,6 +205,11 @@ static int start_inflate(z_stream *s, git_buf *obj, void *out, size_t len)
return
inflate
(
s
,
0
);
}
static
void
abort_inflate
(
z_stream
*
s
)
{
inflateEnd
(
s
);
}
static
int
finish_inflate
(
z_stream
*
s
)
{
int
status
=
Z_OK
;
...
...
@@ -367,6 +372,7 @@ static int inflate_disk_obj(git_rawobj *out, git_buf *obj)
(
used
=
get_object_header
(
&
hdr
,
head
))
==
0
||
!
git_object_typeisloose
(
hdr
.
type
))
{
abort_inflate
(
&
zs
);
giterr_set
(
GITERR_ODB
,
"failed to inflate disk object"
);
return
-
1
;
}
...
...
src/refs.c
View file @
9cc0ba6b
...
...
@@ -277,8 +277,8 @@ int git_reference__read_head(
}
out:
free
(
name
);
git_buf_
clear
(
&
reference
);
git__
free
(
name
);
git_buf_
free
(
&
reference
);
return
error
;
}
...
...
src/remote.c
View file @
9cc0ba6b
...
...
@@ -192,7 +192,7 @@ static int canonicalize_url(git_buf *out, const char *in)
static
int
create_internal
(
git_remote
**
out
,
git_repository
*
repo
,
const
char
*
name
,
const
char
*
url
,
const
char
*
fetch
)
{
git_remote
*
remote
;
git_config
*
config
=
NULL
;
git_config
*
config
_ro
=
NULL
,
*
config_rw
;
git_buf
canonical_url
=
GIT_BUF_INIT
;
git_buf
var
=
GIT_BUF_INIT
;
int
error
=
-
1
;
...
...
@@ -200,7 +200,7 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
/* name is optional */
assert
(
out
&&
repo
&&
url
);
if
((
error
=
git_repository_config_
_weakptr
(
&
config
,
repo
))
<
0
)
if
((
error
=
git_repository_config_
snapshot
(
&
config_ro
,
repo
))
<
0
)
return
error
;
remote
=
git__calloc
(
1
,
sizeof
(
git_remote
));
...
...
@@ -212,7 +212,8 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
(
error
=
canonicalize_url
(
&
canonical_url
,
url
))
<
0
)
goto
on_error
;
remote
->
url
=
apply_insteadof
(
repo
->
_config
,
canonical_url
.
ptr
,
GIT_DIRECTION_FETCH
);
remote
->
url
=
apply_insteadof
(
config_ro
,
canonical_url
.
ptr
,
GIT_DIRECTION_FETCH
);
GITERR_CHECK_ALLOC
(
remote
->
url
);
if
(
name
!=
NULL
)
{
remote
->
name
=
git__strdup
(
name
);
...
...
@@ -221,7 +222,8 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
if
((
error
=
git_buf_printf
(
&
var
,
CONFIG_URL_FMT
,
name
))
<
0
)
goto
on_error
;
if
((
error
=
git_config_set_string
(
config
,
var
.
ptr
,
canonical_url
.
ptr
))
<
0
)
if
((
error
=
git_repository_config__weakptr
(
&
config_rw
,
repo
))
<
0
||
(
error
=
git_config_set_string
(
config_rw
,
var
.
ptr
,
canonical_url
.
ptr
))
<
0
)
goto
on_error
;
}
...
...
@@ -233,10 +235,7 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
if
(
name
&&
(
error
=
write_add_refspec
(
repo
,
name
,
fetch
,
true
))
<
0
)
goto
on_error
;
if
((
error
=
git_repository_config_snapshot
(
&
config
,
repo
))
<
0
)
goto
on_error
;
if
((
error
=
lookup_remote_prune_config
(
remote
,
config
,
name
))
<
0
)
if
((
error
=
lookup_remote_prune_config
(
remote
,
config_ro
,
name
))
<
0
)
goto
on_error
;
/* Move the data over to where the matching functions can find them */
...
...
@@ -260,6 +259,7 @@ on_error:
if
(
error
)
git_remote_free
(
remote
);
git_config_free
(
config_ro
);
git_buf_free
(
&
canonical_url
);
git_buf_free
(
&
var
);
return
error
;
...
...
src/repository.c
View file @
9cc0ba6b
...
...
@@ -2132,7 +2132,8 @@ int git_repository_head_for_worktree(git_reference **out, git_repository *repo,
out:
if
(
error
)
git_reference_free
(
head
);
git_buf_clear
(
&
path
);
git_buf_free
(
&
path
);
return
error
;
}
...
...
src/signature.c
View file @
9cc0ba6b
...
...
@@ -228,8 +228,11 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
const
char
*
time_start
=
email_end
+
2
;
const
char
*
time_end
;
if
(
git__strtol64
(
&
sig
->
when
.
time
,
time_start
,
&
time_end
,
10
)
<
0
)
if
(
git__strtol64
(
&
sig
->
when
.
time
,
time_start
,
&
time_end
,
10
)
<
0
)
{
git__free
(
sig
->
name
);
git__free
(
sig
->
email
);
return
signature_error
(
"invalid Unix timestamp"
);
}
/* do we have a timezone? */
if
(
time_end
+
1
<
buffer_end
)
{
...
...
tests/object/lookup.c
View file @
9cc0ba6b
...
...
@@ -116,6 +116,7 @@ void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void)
cl_git_pass
(
git_object_lookup
(
&
object
,
g_repo
,
&
oid
,
GIT_OBJ_COMMIT
));
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION
,
1
));
git_object_free
(
object
);
git_buf_free
(
&
oldpath
);
git_buf_free
(
&
newpath
);
}
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