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
1202c7ea
Commit
1202c7ea
authored
Feb 04, 2014
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refs: fix leak on successful update
Free the old ref even on success.
parent
fc4728e3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
src/refdb_fs.c
+7
-7
No files found.
src/refdb_fs.c
View file @
1202c7ea
...
...
@@ -941,7 +941,7 @@ static int refdb_fs_backend__write(
refdb_fs_backend
*
backend
=
(
refdb_fs_backend
*
)
_backend
;
git_filebuf
file
=
GIT_FILEBUF_INIT
;
git_reference
*
old_ref
;
int
error
=
0
;
int
error
=
0
,
cmp
;
assert
(
backend
);
...
...
@@ -954,19 +954,20 @@ static int refdb_fs_backend__write(
return
error
;
if
(
old_id
)
{
if
((
error
=
refdb_fs_backend__lookup
(
&
old_ref
,
_backend
,
ref
->
name
))
<
0
)
{
git_filebuf_cleanup
(
&
file
);
return
error
;
}
if
((
error
=
refdb_fs_backend__lookup
(
&
old_ref
,
_backend
,
ref
->
name
))
<
0
)
goto
on_error
;
if
(
old_ref
->
type
==
GIT_REF_SYMBOLIC
)
{
git_reference_free
(
old_ref
);
giterr_set
(
GITERR_REFERENCE
,
"cannot compare id to symbolic reference target"
);
error
=
-
1
;
goto
on_error
;
}
/* Finally we can compare the ids */
if
(
git_oid_cmp
(
old_id
,
&
old_ref
->
target
.
oid
))
{
cmp
=
git_oid_cmp
(
old_id
,
&
old_ref
->
target
.
oid
);
git_reference_free
(
old_ref
);
if
(
cmp
)
{
giterr_set
(
GITERR_REFERENCE
,
"old reference value does not match"
);
error
=
GIT_EMODIFIED
;
goto
on_error
;
...
...
@@ -983,7 +984,6 @@ static int refdb_fs_backend__write(
on_error:
git_filebuf_cleanup
(
&
file
);
git_reference_free
(
old_ref
);
return
error
;
}
...
...
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