[PATCH] name-rev: Fix segmentation fault when using --all

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
I'm not totally sure if adding the check back to the loop is the correct
fix, or if I should have added it to show_name(), but as the empty
entries in the object hash table are a property of that table, I figured
that it's not show_name()'s business to handle that.

 builtin-name-rev.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index cde5de5..f153da0 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++)
-- 
1.5.6.rc1.dirty
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux