Skip to content

Commit

Permalink
name-rev: Fix segmentation fault when using --all
Browse files Browse the repository at this point in the history
In commit da2478d "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>
  • Loading branch information
Björn Steinbrink authored and Junio C Hamano committed Jun 6, 2008
1 parent 4ed19a3 commit a83123d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions builtin-name-rev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down

0 comments on commit a83123d

Please sign in to comment.