Skip to content

Commit

Permalink
register_ref(): make a copy of the bad reference SHA-1
Browse files Browse the repository at this point in the history
The lifetime of the sha1 parameter passed to an each_ref_fn callback
is not guaranteed, so make a copy for later use.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Jun 2, 2013
1 parent 66ce036 commit bf42772
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bisect.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
static struct sha1_array good_revs;
static struct sha1_array skipped_revs;

static const unsigned char *current_bad_sha1;
static unsigned char *current_bad_sha1;

static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
Expand Down Expand Up @@ -404,7 +404,8 @@ static int register_ref(const char *refname, const unsigned char *sha1,
int flags, void *cb_data)
{
if (!strcmp(refname, "bad")) {
current_bad_sha1 = sha1;
current_bad_sha1 = xmalloc(20);
hashcpy(current_bad_sha1, sha1);
} else if (!prefixcmp(refname, "good-")) {
sha1_array_append(&good_revs, sha1);
} else if (!prefixcmp(refname, "skip-")) {
Expand Down

0 comments on commit bf42772

Please sign in to comment.