Commit b20c40a8 by Ben Straub

Don't leak memory when duplicating a NULL signature

parent 9db56cc4
...@@ -76,10 +76,8 @@ static git_blame_hunk* dup_hunk(git_blame_hunk *hunk) ...@@ -76,10 +76,8 @@ static git_blame_hunk* dup_hunk(git_blame_hunk *hunk)
git_oid_cpy(&newhunk->orig_commit_id, &hunk->orig_commit_id); git_oid_cpy(&newhunk->orig_commit_id, &hunk->orig_commit_id);
git_oid_cpy(&newhunk->final_commit_id, &hunk->final_commit_id); git_oid_cpy(&newhunk->final_commit_id, &hunk->final_commit_id);
newhunk->boundary = hunk->boundary; newhunk->boundary = hunk->boundary;
if (hunk->final_signature) newhunk->final_signature = git_signature_dup(hunk->final_signature);
newhunk->final_signature = git_signature_dup(hunk->final_signature); newhunk->orig_signature = git_signature_dup(hunk->orig_signature);
if (hunk->orig_signature)
newhunk->orig_signature = git_signature_dup(hunk->orig_signature);
return newhunk; return newhunk;
} }
......
...@@ -84,8 +84,12 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema ...@@ -84,8 +84,12 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
git_signature *git_signature_dup(const git_signature *sig) git_signature *git_signature_dup(const git_signature *sig)
{ {
git_signature *new = git__calloc(1, sizeof(git_signature)); git_signature *new;
if (sig == NULL)
return NULL;
new = git__calloc(1, sizeof(git_signature));
if (new == NULL) if (new == NULL)
return NULL; return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment