File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,14 @@ static git_blame_hunk* new_hunk(
7676 return hunk ;
7777}
7878
79+ static void free_hunk (git_blame_hunk * hunk )
80+ {
81+ git__free ((void * )hunk -> orig_path );
82+ git_signature_free (hunk -> final_signature );
83+ git_signature_free (hunk -> orig_signature );
84+ git__free (hunk );
85+ }
86+
7987static git_blame_hunk * dup_hunk (git_blame_hunk * hunk )
8088{
8189 git_blame_hunk * newhunk = new_hunk (
@@ -90,17 +98,14 @@ static git_blame_hunk* dup_hunk(git_blame_hunk *hunk)
9098 git_oid_cpy (& newhunk -> orig_commit_id , & hunk -> orig_commit_id );
9199 git_oid_cpy (& newhunk -> final_commit_id , & hunk -> final_commit_id );
92100 newhunk -> boundary = hunk -> boundary ;
93- git_signature_dup (& newhunk -> final_signature , hunk -> final_signature );
94- git_signature_dup (& newhunk -> orig_signature , hunk -> orig_signature );
95- return newhunk ;
96- }
97101
98- static void free_hunk (git_blame_hunk * hunk )
99- {
100- git__free ((void * )hunk -> orig_path );
101- git_signature_free (hunk -> final_signature );
102- git_signature_free (hunk -> orig_signature );
103- git__free (hunk );
102+ if (git_signature_dup (& newhunk -> final_signature , hunk -> final_signature ) < 0 ||
103+ git_signature_dup (& newhunk -> orig_signature , hunk -> orig_signature ) < 0 ) {
104+ free_hunk (newhunk );
105+ return NULL ;
106+ }
107+
108+ return newhunk ;
104109}
105110
106111/* Starting with the hunk that includes start_line, shift all following hunks'
You can’t perform that action at this time.
0 commit comments