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
03d88ed4
Commit
03d88ed4
authored
Aug 02, 2011
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #346 from belkiss/development
Fix memory leak when wrong object type is looked up from cache
parents
80de9ae0
7d3ec3ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletions
+7
-1
src/object.c
+3
-0
tests/t09-tree.c
+4
-1
No files found.
src/object.c
View file @
03d88ed4
...
@@ -117,7 +117,10 @@ int git_object_lookup_prefix(git_object **object_out, git_repository *repo, cons
...
@@ -117,7 +117,10 @@ int git_object_lookup_prefix(git_object **object_out, git_repository *repo, cons
object
=
git_cache_get
(
&
repo
->
objects
,
id
);
object
=
git_cache_get
(
&
repo
->
objects
,
id
);
if
(
object
!=
NULL
)
{
if
(
object
!=
NULL
)
{
if
(
type
!=
GIT_OBJ_ANY
&&
type
!=
object
->
type
)
if
(
type
!=
GIT_OBJ_ANY
&&
type
!=
object
->
type
)
{
git_object_close
(
object
);
return
git__throw
(
GIT_EINVALIDTYPE
,
"Failed to lookup object. The given type does not match the type on the ODB"
);
return
git__throw
(
GIT_EINVALIDTYPE
,
"Failed to lookup object. The given type does not match the type on the ODB"
);
}
*
object_out
=
object
;
*
object_out
=
object
;
return
GIT_SUCCESS
;
return
GIT_SUCCESS
;
...
...
tests/t09-tree.c
View file @
03d88ed4
...
@@ -104,9 +104,11 @@ BEGIN_TEST(read1, "read a tree from the repository")
...
@@ -104,9 +104,11 @@ BEGIN_TEST(read1, "read a tree from the repository")
/* GH-86: git_object_lookup() should also check the type if the object comes from the cache */
/* GH-86: git_object_lookup() should also check the type if the object comes from the cache */
must_be_true
(
git_object_lookup
(
&
obj
,
repo
,
&
id
,
GIT_OBJ_TREE
)
==
0
);
must_be_true
(
git_object_lookup
(
&
obj
,
repo
,
&
id
,
GIT_OBJ_TREE
)
==
0
);
must_be_true
(
obj
!=
NULL
);
git_object_close
(
obj
);
git_object_close
(
obj
);
obj
=
NULL
;
must_be_true
(
git_object_lookup
(
&
obj
,
repo
,
&
id
,
GIT_OBJ_BLOB
)
==
GIT_EINVALIDTYPE
);
must_be_true
(
git_object_lookup
(
&
obj
,
repo
,
&
id
,
GIT_OBJ_BLOB
)
==
GIT_EINVALIDTYPE
);
git_object_close
(
obj
);
must_be_true
(
obj
==
NULL
);
entry
=
git_tree_entry_byname
(
tree
,
"README"
);
entry
=
git_tree_entry_byname
(
tree
,
"README"
);
must_be_true
(
entry
!=
NULL
);
must_be_true
(
entry
!=
NULL
);
...
@@ -114,6 +116,7 @@ BEGIN_TEST(read1, "read a tree from the repository")
...
@@ -114,6 +116,7 @@ BEGIN_TEST(read1, "read a tree from the repository")
must_be_true
(
strcmp
(
git_tree_entry_name
(
entry
),
"README"
)
==
0
);
must_be_true
(
strcmp
(
git_tree_entry_name
(
entry
),
"README"
)
==
0
);
must_pass
(
git_tree_entry_2object
(
&
obj
,
repo
,
entry
));
must_pass
(
git_tree_entry_2object
(
&
obj
,
repo
,
entry
));
must_be_true
(
obj
!=
NULL
);
git_object_close
(
obj
);
git_object_close
(
obj
);
git_tree_close
(
tree
);
git_tree_close
(
tree
);
...
...
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