[PATCH v3 17/22] remote: avoid passing NULL to read_ref()
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Sep 15, 2011, 21:10 UTC
- Message-ID
- <1316121043-29367-18-git-send-email-mhagger@alum.mit.edu>
- In-Reply-To
- <1316121043-29367-1-git-send-email-mhagger@alum.mit.edu>
read_ref() can (and in test t5800, actually *does*) return NULL. Don't pass the NULL along to read_ref(). Coincidentally, this mistake didn't make resolve_ref() blow up, but upcoming changes to resolve_ref() will make it less forgiving.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> --- transport-helper.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c index 0713126..6f227e2 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -446,8 +446,10 @@ static int fetch_with_import(struct transport *transport, private = apply_refspecs(data->refspecs, data->refspec_nr, posn->name); else private = xstrdup(posn->name); - read_ref(private, posn->old_sha1); - free(private); + if (private) { + read_ref(private, posn->old_sha1); + free(private); + } } strbuf_release(&buf); return 0;
-- 1.7.6.8.gd2879