mirror of
https://github.com/git/git.git
synced 2024-09-29 05:01:36 +02:00
add_commit_patch_id(): avoid allocating memory unnecessarily
It would appear that we allocate (and forget to release) memory if the patch ID is not even defined. Reported by the Coverity tool. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b6b066adf9
commit
5748693b91
@ -99,11 +99,12 @@ struct patch_id *has_commit_patch_id(struct commit *commit,
|
|||||||
struct patch_id *add_commit_patch_id(struct commit *commit,
|
struct patch_id *add_commit_patch_id(struct commit *commit,
|
||||||
struct patch_ids *ids)
|
struct patch_ids *ids)
|
||||||
{
|
{
|
||||||
struct patch_id *key = xcalloc(1, sizeof(*key));
|
struct patch_id *key;
|
||||||
|
|
||||||
if (!patch_id_defined(commit))
|
if (!patch_id_defined(commit))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
key = xcalloc(1, sizeof(*key));
|
||||||
if (init_patch_id_entry(key, commit, ids)) {
|
if (init_patch_id_entry(key, commit, ids)) {
|
||||||
free(key);
|
free(key);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user