summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonnie Sahlberg <sahlberg@google.com>2014-05-15 10:29:35 -0700
committerJunio C Hamano <gitster@pobox.com>2014-05-15 14:11:36 -0700
commit4f20f894fc316c6ce9b87e834272fd1a72c9b807 (patch)
tree54a9b800aec1fa573bd3c6e91c591255ab15dee9
parent1530c4a53e9b8c30b033bcbb9244e68d372b4fce (diff)
downloadgit-4f20f894fc316c6ce9b87e834272fd1a72c9b807.tar.gz
refs.c: free the transaction before returning when number of updates is 0
We have to free the transaction before returning in the early check for 'return early if number of updates == 0' or else the following code would create a memory leak with the transaction never being freed : t = ref_transaction_begin() ref_transaction_commit(t) Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index 0476892f70..4a37f87d29 100644
--- a/refs.c
+++ b/refs.c
@@ -3471,8 +3471,10 @@ int ref_transaction_commit(struct ref_transaction *transaction,
int n = transaction->nr;
struct ref_update **updates = transaction->updates;
- if (!n)
+ if (!n) {
+ ref_transaction_free(transaction);
return 0;
+ }
/* Allocate work space */
delnames = xmalloc(sizeof(*delnames) * n);