Skip to content

Commit d51b720

Browse files
mhaggergitster
authored andcommitted
remote: avoid passing NULL to read_ref()
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>
1 parent c28cce5 commit d51b720

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

transport-helper.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,10 @@ static int fetch_with_import(struct transport *transport,
446446
private = apply_refspecs(data->refspecs, data->refspec_nr, posn->name);
447447
else
448448
private = xstrdup(posn->name);
449-
read_ref(private, posn->old_sha1);
450-
free(private);
449+
if (private) {
450+
read_ref(private, posn->old_sha1);
451+
free(private);
452+
}
451453
}
452454
strbuf_release(&buf);
453455
return 0;

0 commit comments

Comments
 (0)