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
d88e5001
Commit
d88e5001
authored
Jun 29, 2016
by
Edward Thomson
Committed by
GitHub
Jun 29, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3842 from pks-t/pks/double-free
blame: increment reference count for origin's commit
parents
20302aa4
21766702
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
src/blame_git.c
+18
-8
No files found.
src/blame_git.c
View file @
d88e5001
...
...
@@ -37,25 +37,27 @@ static void origin_decref(git_blame__origin *o)
static
int
make_origin
(
git_blame__origin
**
out
,
git_commit
*
commit
,
const
char
*
path
)
{
git_blame__origin
*
o
;
git_object
*
blob
;
size_t
path_len
=
strlen
(
path
),
alloc_len
;
int
error
=
0
;
if
((
error
=
git_object_lookup_bypath
(
&
blob
,
(
git_object
*
)
commit
,
path
,
GIT_OBJ_BLOB
))
<
0
)
return
error
;
GITERR_CHECK_ALLOC_ADD
(
&
alloc_len
,
sizeof
(
*
o
),
path_len
);
GITERR_CHECK_ALLOC_ADD
(
&
alloc_len
,
alloc_len
,
1
);
o
=
git__calloc
(
1
,
alloc_len
);
GITERR_CHECK_ALLOC
(
o
);
o
->
commit
=
commit
;
o
->
blob
=
(
git_blob
*
)
blob
;
o
->
refcnt
=
1
;
strcpy
(
o
->
path
,
path
);
if
(
!
(
error
=
git_object_lookup_bypath
((
git_object
**
)
&
o
->
blob
,
(
git_object
*
)
commit
,
path
,
GIT_OBJ_BLOB
)))
{
*
out
=
o
;
}
else
{
origin_decref
(
o
);
}
return
error
;
*
out
=
o
;
return
0
;
}
/* Locate an existing origin or create a new one. */
...
...
@@ -529,8 +531,16 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
goto
finish
;
porigin
=
find_origin
(
blame
,
p
,
origin
);
if
(
!
porigin
)
if
(
!
porigin
)
{
/*
* We only have to decrement the parent's
* reference count when no porigin has
* been created, as otherwise the commit
* is assigned to the created object.
*/
git_commit_free
(
p
);
continue
;
}
if
(
porigin
->
blob
&&
origin
->
blob
&&
!
git_oid_cmp
(
git_blob_id
(
porigin
->
blob
),
git_blob_id
(
origin
->
blob
)))
{
pass_whole_blame
(
blame
,
origin
,
porigin
);
...
...
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