From: Johannes Schindelin Date: Wed, 18 Feb 2009 18:14:59 +0000 (+0100) Subject: Avoid segfault with 'git branch' when the HEAD is detached X-Git-Tag: v1.6.3-rc0~215^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=45e2b61;p=git.git 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 --- diff --git a/builtin-branch.c b/builtin-branch.c index 7607f6ab9..6106a1abd 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);