summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-01-19 21:58:31 -0800
committerJunio C Hamano <gitster@pobox.com>2009-01-19 21:58:31 -0800
commit39765e5941d36f74cec4764d315da0ba5743547c (patch)
treec6bfc94880ef6087aa0279be2275520489f4efec /sha1_name.c
parentc829774c30e10473d3139edf92a4afe36e8abdc2 (diff)
downloadgit-39765e5941d36f74cec4764d315da0ba5743547c.tar.gz
interpret_nth_last_branch(): plug small memleak
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sha1_name.c b/sha1_name.c
index f54b6cb36a..4c0370bb79 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -754,7 +754,7 @@ static int grab_nth_branch_switch(unsigned char *osha1, unsigned char *nsha1,
int interpret_nth_last_branch(const char *name, struct strbuf *buf)
{
long nth;
- int i;
+ int i, retval;
struct grab_nth_branch_switch_cbdata cb;
const char *brace;
char *num_end;
@@ -774,17 +774,21 @@ int interpret_nth_last_branch(const char *name, struct strbuf *buf)
for (i = 0; i < nth; i++)
strbuf_init(&cb.buf[i], 20);
cb.cnt = 0;
+ retval = 0;
for_each_reflog_ent("HEAD", grab_nth_branch_switch, &cb);
if (cb.cnt < nth)
- return 0;
+ goto release_return;
i = cb.cnt % nth;
strbuf_reset(buf);
strbuf_add(buf, cb.buf[i].buf, cb.buf[i].len);
+ retval = brace-name+1;
+
+release_return:
for (i = 0; i < nth; i++)
strbuf_release(&cb.buf[i]);
free(cb.buf);
- return brace-name+1;
+ return retval;
}
/*