threads / patch / 18906

patchget_local_heads(): do not return random pointer if there is no head

Subject: [PATCH] get_local_heads(): do not return random pointer if there is no head

## tl;dr

2 messages between Apr 16, 2009 and Apr 18, 2009. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Nguyễn Thái Ngọc Duy· Apr 16, 2009, 22:16 UTC · lore
it's silly to do this:
mkdir foo && cd foo && git init && git push somewhere.git
but segfault should not happen even in that case.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 remote.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to remote.c +1 −1
diff --git a/remote.c b/remote.c
index d12140e..63f749c 100644
--- a/remote.c
+++ b/remote.c
@@ -1493,7 +1493,7 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla
 
 struct ref *get_local_heads(void)
 {
-	struct ref *local_refs, **local_tail = &local_refs;
+	struct ref *local_refs = NULL, **local_tail = &local_refs;
 	for_each_ref(one_local_ref, &local_tail);
 	return local_refs;
 }
-- 
1.6.2.2.693.g5a1be
Junio C Hamano· Apr 18, 2009, 05:02 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH] get_local_heads(): do not return random pointer if there is no head

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 5 quoted lines
> it's silly to do this:
>
> mkdir foo && cd foo && git init && git push somewhere.git
>
> but segfault should not happen even in that case.
Thanks.

← back to recent threads