Skip to content

Commit

Permalink
remote: avoid passing NULL to read_ref()
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Oct 5, 2011
1 parent c28cce5 commit d51b720
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d51b720

Please sign in to comment.