Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2017-05-04 16:55:38 +0300
committerJunio C Hamano <gitster@pobox.com>2017-05-08 06:18:19 +0300
commit5748693b9123f55363211d18e8074db5e1b8384e (patch)
tree399bd14bc8d4ac40f8426163ba44e500041f5063 /patch-ids.c
parentb6b066adf9e1e970a6d8295db630ab1e1f3bc71c (diff)
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>
Diffstat (limited to 'patch-ids.c')
-rw-r--r--patch-ids.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/patch-ids.c b/patch-ids.c
index fa8f11de82..92eba7a059 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -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_ids *ids)
{
- struct patch_id *key = xcalloc(1, sizeof(*key));
+ struct patch_id *key;
if (!patch_id_defined(commit))
return NULL;
+ key = xcalloc(1, sizeof(*key));
if (init_patch_id_entry(key, commit, ids)) {
free(key);
return NULL;