From 45e2b6140147d7a8b2cd68399e4d52d5d8d7b5be Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2009 19:14:59 +0100 Subject: [PATCH] Avoid segfault with 'git branch' when the HEAD is detached A recent addition to the ref_item struct was not taken care of, leading to a segmentation fault when accessing the (uninitialized) "dest" member. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-branch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin-branch.c b/builtin-branch.c index 7607f6ab9c..6106a1abd5 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -432,7 +432,9 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str is_descendant_of(head_commit, with_commit)) { struct ref_item item; item.name = xstrdup("(no branch)"); + item.len = strlen(item.name); item.kind = REF_LOCAL_BRANCH; + item.dest = NULL; item.commit = head_commit; if (strlen(item.name) > ref_list.maxwidth) ref_list.maxwidth = strlen(item.name); -- 2.11.4.GIT