Skip to content

Commit a83123d

Browse files
dotdashgitster
authored andcommitted
name-rev: Fix segmentation fault when using --all
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ed19a3 commit a83123d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

builtin-name-rev.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
280280
int i, max;
281281

282282
max = get_max_object_index();
283-
for (i = 0; i < max; i++)
284-
show_name(get_indexed_object(i), NULL,
283+
for (i = 0; i < max; i++) {
284+
struct object *obj = get_indexed_object(i);
285+
if (!obj)
286+
continue;
287+
show_name(obj, NULL,
285288
always, allow_undefined, data.name_only);
289+
}
286290
} else {
287291
int i;
288292
for (i = 0; i < revs.nr; i++)

0 commit comments

Comments
 (0)