mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-20 07:52:43 +00:00
Don't leak memory when duplicating a NULL signature
This commit is contained in:
parent
9db56cc4a7
commit
b20c40a8d6
@ -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
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user