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
da5b1e1c
Commit
da5b1e1c
authored
Jul 07, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
index: Fix memory leak on OOM
parent
2b5af615
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
src/index.c
+17
-4
No files found.
src/index.c
View file @
da5b1e1c
...
...
@@ -380,8 +380,12 @@ static int index_insert(git_index *index, const git_index_entry *source_entry, i
* replacing is not requested: just insert entry at the end;
* the index is no longer sorted
*/
if
(
!
replace
)
return
git_vector_insert
(
&
index
->
entries
,
entry
);
if
(
!
replace
)
{
if
(
git_vector_insert
(
&
index
->
entries
,
entry
)
<
GIT_SUCCESS
)
goto
cleanup_oom
;
return
GIT_SUCCESS
;
}
/* look if an entry with this path already exists */
position
=
git_index_find
(
index
,
source_entry
->
path
);
...
...
@@ -390,8 +394,12 @@ static int index_insert(git_index *index, const git_index_entry *source_entry, i
* if no entry exists add the entry at the end;
* the index is no longer sorted
*/
if
(
position
==
GIT_ENOTFOUND
)
return
git_vector_insert
(
&
index
->
entries
,
entry
);
if
(
position
==
GIT_ENOTFOUND
)
{
if
(
git_vector_insert
(
&
index
->
entries
,
entry
)
<
GIT_SUCCESS
)
goto
cleanup_oom
;
return
GIT_SUCCESS
;
}
/* exists, replace it */
entry_array
=
(
git_index_entry
**
)
index
->
entries
.
contents
;
...
...
@@ -400,6 +408,11 @@ static int index_insert(git_index *index, const git_index_entry *source_entry, i
entry_array
[
position
]
=
entry
;
return
GIT_SUCCESS
;
cleanup_oom:
free
((
char
*
)
entry
->
path
);
free
(
entry
);
return
GIT_ENOMEM
;;
}
static
int
index_init_entry
(
git_index_entry
*
entry
,
git_index
*
index
,
const
char
*
rel_path
,
int
stage
)
...
...
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