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
9568660f
Commit
9568660f
authored
Jun 26, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
diff: fix leaks in diff printing
parent
354268ca
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
src/diff_patch.c
+9
-1
src/diff_print.c
+3
-0
tests/diff/binary.c
+5
-1
No files found.
src/diff_patch.c
View file @
9568660f
...
...
@@ -325,9 +325,14 @@ static int diff_binary(git_diff_output *output, git_patch *patch)
old_data
,
old_len
,
new_data
,
new_len
))
<
0
)
return
error
;
return
giterr_set_after_callback_function
(
error
=
giterr_set_after_callback_function
(
output
->
binary_cb
(
patch
->
delta
,
&
binary
,
output
->
payload
),
"git_patch"
);
git__free
((
char
*
)
binary
.
old_file
.
data
);
git__free
((
char
*
)
binary
.
new_file
.
data
);
return
error
;
}
static
int
diff_patch_generate
(
git_patch
*
patch
,
git_diff_output
*
output
)
...
...
@@ -377,6 +382,9 @@ static void diff_patch_free(git_patch *patch)
git__free
((
char
*
)
patch
->
diff_opts
.
old_prefix
);
git__free
((
char
*
)
patch
->
diff_opts
.
new_prefix
);
git__free
((
char
*
)
patch
->
binary
.
old_file
.
data
);
git__free
((
char
*
)
patch
->
binary
.
new_file
.
data
);
if
(
patch
->
flags
&
GIT_DIFF_PATCH_ALLOCATED
)
git__free
(
patch
);
}
...
...
src/diff_print.c
View file @
9568660f
...
...
@@ -578,6 +578,9 @@ int git_diff_print(
giterr_set_after_callback_function
(
error
,
"git_diff_print"
);
}
git__free
(
pi
.
nfile
);
git__free
(
pi
.
ofile
);
git_buf_free
(
&
buf
);
return
error
;
...
...
tests/diff/binary.c
View file @
9568660f
...
...
@@ -4,6 +4,7 @@
#include "buffer.h"
#include "filebuf.h"
#include "repository.h"
static
git_repository
*
repo
;
...
...
@@ -497,7 +498,7 @@ void test_diff_binary__blob_to_blob(void)
opts
.
id_abbrev
=
GIT_OID_HEXSZ
;
repo
=
cl_git_sandbox_init
(
"renames"
);
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
cl_git_pass
(
git_repository_index
__weakptr
(
&
index
,
repo
));
cl_git_append2file
(
"renames/untimely.txt"
,
"Oh that crazy Kipling!
\r\n
"
);
cl_git_pass
(
git_index_add_bypath
(
index
,
"untimely.txt"
));
...
...
@@ -532,4 +533,7 @@ void test_diff_binary__blob_to_blob(void)
git__free
(
diff_data
.
old_path
);
git__free
(
diff_data
.
new_path
);
git_buf_free
(
&
diff_data
.
old_binary_base85
);
git_buf_free
(
&
diff_data
.
new_binary_base85
);
}
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