* [PATCH] push: fix segfault when HEAD points nowhere
@ 2013-01-31 12:22 Fraser Tweedale
2013-01-31 16:06 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Fraser Tweedale @ 2013-01-31 12:22 UTC (permalink / raw)
To: git; +Cc: Fraser Tweedale
When reporting the outcome of a push, a segfault occurs if HEAD does
not point somewhere. Check that HEAD points somewhere before trying
to strcmp it.
Signed-off-by: Fraser Tweedale <frase@frase.id.au>
---
transport.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/transport.c b/transport.c
index 9932f40..b9306ef 100644
--- a/transport.c
+++ b/transport.c
@@ -741,7 +741,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;
--
1.8.1.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] push: fix segfault when HEAD points nowhere
2013-01-31 12:22 [PATCH] push: fix segfault when HEAD points nowhere Fraser Tweedale
@ 2013-01-31 16:06 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2013-01-31 16:06 UTC (permalink / raw)
To: Fraser Tweedale; +Cc: git
Fraser Tweedale <frase@frase.id.au> writes:
> When reporting the outcome of a push, a segfault occurs if HEAD does
> not point somewhere. Check that HEAD points somewhere before trying
> to strcmp it.
>
> Signed-off-by: Fraser Tweedale <frase@frase.id.au>
> ---
> transport.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/transport.c b/transport.c
> index 9932f40..b9306ef 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -741,7 +741,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;
Wow.
This is a bug that is hard to trigger by just using the software
(you have to be doubly insane to be on an unborn branch and pushing
out a branch that is not the one you are currently on) and one has
to look at the code to hunt for it.
The fix looks correct. Thank you very much for spotting.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-31 16:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-31 12:22 [PATCH] push: fix segfault when HEAD points nowhere Fraser Tweedale
2013-01-31 16:06 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox