Avoid segfault with 'git branch' when the HEAD is detached
[gitweb.git] / builtin-branch.c
index 7607f6ab9c612ef49b792f38a334374e11374e9c..6106a1abd5d5a001a44d06a66bc0ea2e47f5247d 100644 (file)
@@ -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);