@matheusbsbs / matheus-bagliano / commits / 55f0566f6d
Fork 0

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

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Apr 17, 2009 at 08:16 UTC 55f0566f6d7269a56751333e0943b50237ce6a85
1 file changed +1 -1
remote.c
+1 -1
@@ -1504,7 +1504,7 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla
1504
1505 struct ref *get_local_heads(void)
1506 {
1507 - struct ref *local_refs, **local_tail = &local_refs;
1507 + struct ref *local_refs = NULL, **local_tail = &local_refs;
1508 for_each_ref(one_local_ref, &local_tail);
1509 return local_refs;
1510 }