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
66d9e046
Commit
66d9e046
authored
Mar 04, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2157 from libgit2/cmn/write-object-mem
pack-objects: free memory safely
parents
0a62caf4
a14aa1e7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
src/pack-objects.c
+17
-10
No files found.
src/pack-objects.c
View file @
66d9e046
...
...
@@ -288,18 +288,21 @@ static int write_object(
git_odb_object
*
obj
=
NULL
;
git_otype
type
;
unsigned
char
hdr
[
10
],
*
zbuf
=
NULL
;
void
*
delta_data
=
NULL
;
void
*
data
;
void
*
data
=
NULL
;
size_t
hdr_len
,
zbuf_len
=
COMPRESS_BUFLEN
,
data_len
;
int
error
;
/*
* If we have a delta base, let's use the delta to save space.
* Otherwise load the whole object. 'data' ends up pointing to
* whatever data we want to put into the packfile.
*/
if
(
po
->
delta
)
{
if
(
po
->
delta_data
)
d
elta_d
ata
=
po
->
delta_data
;
else
if
((
error
=
get_delta
(
&
d
elta_d
ata
,
pb
->
odb
,
po
))
<
0
)
data
=
po
->
delta_data
;
else
if
((
error
=
get_delta
(
&
data
,
pb
->
odb
,
po
))
<
0
)
goto
done
;
data
=
delta_data
;
data_len
=
po
->
delta_size
;
type
=
GIT_OBJ_REF_DELTA
;
}
else
{
...
...
@@ -346,13 +349,17 @@ static int write_object(
zbuf_len
=
COMPRESS_BUFLEN
;
/* reuse buffer */
}
if
(
po
->
delta
)
git__free
(
delta_data
);
}
if
(
po
->
delta_data
)
{
git__free
(
po
->
delta_data
);
/*
* If po->delta is true, data is a delta and it is our
* responsibility to free it (otherwise it's a git_object's
* data). We set po->delta_data to NULL in case we got the
* data from there instead of get_delta(). If we didn't,
* there's no harm.
*/
if
(
po
->
delta
)
{
git__free
(
data
);
po
->
delta_data
=
NULL
;
}
...
...
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