Skip to content

Commit

Permalink
Merge branch 'mh/packed-refs-do-one-ref-recursion'
Browse files Browse the repository at this point in the history
Fix a NULL-pointer dereference during nested iterations over
references (for example, when replace references are being used).

* mh/packed-refs-do-one-ref-recursion:
  do_one_ref(): save and restore value of current_ref
  • Loading branch information
Junio C Hamano committed Jul 31, 2013
2 parents 35f5eaa + d0cf51e commit f1093b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,18 +634,22 @@ struct ref_entry_cb {
static int do_one_ref(struct ref_entry *entry, void *cb_data)
{
struct ref_entry_cb *data = cb_data;
struct ref_entry *old_current_ref;
int retval;

if (prefixcmp(entry->name, data->base))
return 0;

if (!(data->flags & DO_FOR_EACH_INCLUDE_BROKEN) &&
!ref_resolves_to_object(entry))
return 0;

/* Store the old value, in case this is a recursive call: */
old_current_ref = current_ref;
current_ref = entry;
retval = data->fn(entry->name + data->trim, entry->u.value.sha1,
entry->flag, data->cb_data);
current_ref = NULL;
current_ref = old_current_ref;
return retval;
}

Expand Down

0 comments on commit f1093b0

Please sign in to comment.