OSDN Git Service

write_entry: fix leak when retrying delayed filter
[git-core/git.git] / patch-ids.c
index fa8f11d..92eba7a 100644 (file)
@@ -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;