summaryrefslogtreecommitdiff
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2013-05-25 09:08:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-06-02 22:28:47 (GMT)
commitf83918edcb6fbcd1c5d8378c11e57edcc47bd232 (patch)
treedeba23698bc8bfcc3498d6944676a971a0f176c1 /builtin/fetch.c
parent5b87d8d3f53c1dfb54027123af612488abc85006 (diff)
downloadgit-f83918edcb6fbcd1c5d8378c11e57edcc47bd232.zip
git-f83918edcb6fbcd1c5d8378c11e57edcc47bd232.tar.gz
git-f83918edcb6fbcd1c5d8378c11e57edcc47bd232.tar.bz2
add_existing(): do not retain a reference to sha1
Its lifetime is not guaranteed, so make a copy. Free the memory when the string_list is cleared. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 48df5fa..fa6fe44 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -571,7 +571,8 @@ static int add_existing(const char *refname, const unsigned char *sha1,
{
struct string_list *list = (struct string_list *)cbdata;
struct string_list_item *item = string_list_insert(list, refname);
- item->util = (void *)sha1;
+ item->util = xmalloc(20);
+ hashcpy(item->util, sha1);
return 0;
}
@@ -636,7 +637,7 @@ static void find_non_local_tags(struct transport *transport,
item = string_list_insert(&remote_refs, ref->name);
item->util = (void *)ref->old_sha1;
}
- string_list_clear(&existing_refs, 0);
+ string_list_clear(&existing_refs, 1);
/*
* We may have a final lightweight tag that needs to be
@@ -782,7 +783,7 @@ static int do_fetch(struct transport *transport,
}
cleanup:
- string_list_clear(&existing_refs, 0);
+ string_list_clear(&existing_refs, 1);
return retcode;
}