diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-07-31 12:38:11 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-31 12:38:12 -0700 |
commit | f1093b0f60ef28c3dab63a7d73f284426705cea1 (patch) | |
tree | 9389ae2b2cdfc51ad9ea0e6075a133f04c136593 /refs.c | |
parent | 35f5eaa2eedcd7145ee59ff5ff2cb48e71270b81 (diff) | |
parent | d0cf51e9401b6486aaecfea5dc3b01c3bb00f271 (diff) | |
download | git-f1093b0f60ef28c3dab63a7d73f284426705cea1.tar.gz |
Merge branch 'mh/packed-refs-do-one-ref-recursion'
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
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -634,7 +634,9 @@ 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; @@ -642,10 +644,12 @@ static int do_one_ref(struct ref_entry *entry, void *cb_data) !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; } |