{"thread":{"id":"13819","subject":"[PATCH] name-rev: Fix segmentation fault when using --all","startedAt":"2008-06-05T23:31:55Z","lastAt":"2008-06-06T04:06:32Z","messageCount":2,"participants":["Björn Steinbrink","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"78841","messageId":"20080605233155.GA21698@atjola.homenet","threadId":"13819","inReplyTo":null,"subject":"[PATCH] name-rev: Fix segmentation fault when using --all","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-06-05T23:31:55Z","receivedAt":"2008-06-05T23:31:55Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"In commit da2478db \"describe --always: fall back to showing an\nabbreviated object name\" we lost the check that skips empty entries in\nthe object hash table when iterating over it in cmd_name_rev. That may\ncause a NULL pointer being handed to show_name(), leading to a\nsegmentation fault. So add that check back again.\n\nSigned-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>\n---\nI'm not totally sure if adding the check back to the loop is the correct\nfix, or if I should have added it to show_name(), but as the empty\nentries in the object hash table are a property of that table, I figured\nthat it's not show_name()'s business to handle that.\n\n builtin-name-rev.c |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-name-rev.c b/builtin-name-rev.c\nindex cde5de5..f153da0 100644\n--- a/builtin-name-rev.c\n+++ b/builtin-name-rev.c\n@@ -280,9 +280,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\tint i, max;\n \n \t\tmax = get_max_object_index();\n-\t\tfor (i = 0; i < max; i++)\n-\t\t\tshow_name(get_indexed_object(i), NULL,\n+\t\tfor (i = 0; i < max; i++) {\n+\t\t\tstruct object *obj = get_indexed_object(i);\n+\t\t\tif (!obj)\n+\t\t\t\tcontinue;\n+\t\t\tshow_name(obj, NULL,\n \t\t\t\t  always, allow_undefined, data.name_only);\n+\t\t}\n \t} else {\n \t\tint i;\n \t\tfor (i = 0; i < revs.nr; i++)\n-- \n1.5.6.rc1.dirty\n"},{"id":"78859","messageId":"7v4p87xl4n.fsf@gitster.siamese.dyndns.org","threadId":"13819","inReplyTo":"20080605233155.GA21698@atjola.homenet","subject":"Re: [PATCH] name-rev: Fix segmentation fault when using --all","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-06T04:06:32Z","receivedAt":"2008-06-06T04:06:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.  Although I am unsure what \"name-rev --all\" is good for ;-), the\nfix looks good.\n"}]}