Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
add_commit_patch_id(): avoid allocating memory unnecessarily
author
Johannes Schindelin
<johannes.schindelin@gmx.de>
Thu, 4 May 2017 13:55:38 +0000
(15:55 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 8 May 2017 03:18:19 +0000
(12:18 +0900)
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>
patch-ids.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
b6b066a
)
diff --git
a/patch-ids.c
b/patch-ids.c
index fa8f11de82657c3edf4e5c0869d76ae6f12b57bb..92eba7a059e89873e2d94fd5ee37a92b887bde4c 100644
(file)
--- 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;