summaryrefslogtreecommitdiff
path: root/builtin-name-rev.c
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2008-06-06 01:31:55 +0200
committerJunio C Hamano <gitster@pobox.com>2008-06-05 21:01:45 -0700
commita83123deecfdd5078c2e16166576fb17add194b2 (patch)
tree4fad04c70460716fb1539ece714288e314d6579d /builtin-name-rev.c
parent4ed19a3c178d22fbd424af78b42b65533a8d1ebb (diff)
downloadgit-a83123deecfdd5078c2e16166576fb17add194b2.tar.gz
name-rev: Fix segmentation fault when using --all
In commit da2478db "describe --always: fall back to showing an abbreviated object name" we lost the check that skips empty entries in the object hash table when iterating over it in cmd_name_rev. That may cause a NULL pointer being handed to show_name(), leading to a segmentation fault. So add that check back again. Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-name-rev.c')
-rw-r--r--builtin-name-rev.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index 384da4db13..521f061c9e 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -280,9 +280,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
int i, max;
max = get_max_object_index();
- for (i = 0; i < max; i++)
- show_name(get_indexed_object(i), NULL,
+ for (i = 0; i < max; i++) {
+ struct object *obj = get_indexed_object(i);
+ if (!obj)
+ continue;
+ show_name(obj, NULL,
always, allow_undefined, data.name_only);
+ }
} else {
int i;
for (i = 0; i < revs.nr; i++)