[PATCH] Avoid segfault with 'git branch' when the HEAD is detached

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <johannes.schindelin@xxxxxx>
---

	Unfortunately not found by valgrind.

 builtin-branch.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/builtin-branch.c b/builtin-branch.c
index 8c37c78..ded0a82 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -441,7 +441,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);
-- 
1.6.2.rc1.349.g70b801
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux