Don't leak memory when duplicating a NULL signature
diff --git a/src/blame.c b/src/blame.c
index c5b7083..219a6bf 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -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->final_commit_id, &hunk->final_commit_id);
newhunk->boundary = hunk->boundary;
- if (hunk->final_signature)
- newhunk->final_signature = git_signature_dup(hunk->final_signature);
- if (hunk->orig_signature)
- newhunk->orig_signature = git_signature_dup(hunk->orig_signature);
+ newhunk->final_signature = git_signature_dup(hunk->final_signature);
+ newhunk->orig_signature = git_signature_dup(hunk->orig_signature);
return newhunk;
}
diff --git a/src/signature.c b/src/signature.c
index 52ca2b3..ec51a42 100644
--- a/src/signature.c
+++ b/src/signature.c
@@ -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 *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)
return NULL;