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
53412305
Commit
53412305
authored
May 19, 2016
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree: plug leaks in the tree updater
parent
6ee08d2c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
src/tree.c
+11
-3
tests/object/tree/update.c
+2
-1
No files found.
src/tree.c
View file @
53412305
...
...
@@ -1216,22 +1216,29 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
{
/* Make sure we're replacing something of the same type */
tree_stack_entry
*
last
=
git_array_last
(
stack
);
c
onst
c
har
*
basename
=
git_path_basename
(
update
->
path
);
char
*
basename
=
git_path_basename
(
update
->
path
);
const
git_tree_entry
*
e
=
git_treebuilder_get
(
last
->
bld
,
basename
);
if
(
e
&&
git_tree_entry_type
(
e
)
!=
git_object__type_from_filemode
(
update
->
filemode
))
{
git__free
(
basename
);
giterr_set
(
GITERR_TREE
,
"Cannot replace '%s' with '%s' at '%s'"
,
git_object_type2string
(
git_tree_entry_type
(
e
)),
git_object_type2string
(
git_object__type_from_filemode
(
update
->
filemode
)),
update
->
path
);
return
-
1
;
error
=
-
1
;
goto
cleanup
;
}
error
=
git_treebuilder_insert
(
NULL
,
last
->
bld
,
basename
,
&
update
->
id
,
update
->
filemode
);
git__free
(
basename
);
break
;
}
case
GIT_TREE_UPDATE_REMOVE
:
error
=
git_treebuilder_remove
(
git_array_last
(
stack
)
->
bld
,
git_path_basename
(
update
->
path
));
{
char
*
basename
=
git_path_basename
(
update
->
path
);
error
=
git_treebuilder_remove
(
git_array_last
(
stack
)
->
bld
,
basename
);
git__free
(
basename
);
break
;
}
default
:
giterr_set
(
GITERR_TREE
,
"unkown action for update"
);
error
=
-
1
;
...
...
@@ -1275,6 +1282,7 @@ cleanup:
}
}
git_buf_free
(
&
component
);
git_array_clear
(
stack
);
git_vector_free
(
&
entries
);
return
error
;
...
...
tests/object/tree/update.c
View file @
53412305
...
...
@@ -127,7 +127,6 @@ void test_object_tree_update__add_blobs(void)
};
cl_git_pass
(
git_oid_fromstr
(
&
base_id
,
"c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"
));
cl_git_pass
(
git_tree_lookup
(
&
base_tree
,
g_repo
,
&
base_id
));
entry
.
mode
=
GIT_FILEMODE_BLOB
;
cl_git_pass
(
git_oid_fromstr
(
&
entry
.
id
,
"fa49b077972391ad58037050f2a75f74e3671e92"
));
...
...
@@ -161,6 +160,8 @@ void test_object_tree_update__add_blobs(void)
cl_assert_equal_oid
(
&
tree_index_id
,
&
tree_updater_id
);
}
git_tree_free
(
base_tree
);
}
void
test_object_tree_update__add_conflict
(
void
)
...
...
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