diff options
author | Ronnie Sahlberg <sahlberg@google.com> | 2014-05-15 10:29:35 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-05-15 14:11:36 -0700 |
commit | 4f20f894fc316c6ce9b87e834272fd1a72c9b807 (patch) | |
tree | 54a9b800aec1fa573bd3c6e91c591255ab15dee9 | |
parent | 1530c4a53e9b8c30b033bcbb9244e68d372b4fce (diff) | |
download | git-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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); |