Skip to content

Commit

Permalink
push: fix segfault when HEAD points nowhere
Browse files Browse the repository at this point in the history
After a push of a branch other than the current branch fails in
a no-ff error and if you are still on an unborn branch, the code
recently added to report the failure dereferenced a null pointer
while checking the name of the current branch.

Signed-off-by: Fraser Tweedale <frase@frase.id.au>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Fraser Tweedale authored and Junio C Hamano committed Jan 31, 2013
1 parent f25950f commit 1d2c14d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ void transport_print_push_status(const char *dest, struct ref *refs,
n += print_one_push_status(ref, dest, n, porcelain);
if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD &&
*nonfastforward != NON_FF_HEAD) {
if (!strcmp(head, ref->name))
if (head != NULL && !strcmp(head, ref->name))
*nonfastforward = NON_FF_HEAD;
else
*nonfastforward = NON_FF_OTHER;
Expand Down

0 comments on commit 1d2c14d

Please sign in to comment.