{"thread":{"id":"26478","subject":"[PATCH] string_list_append: always set util pointer to NULL","startedAt":"2011-02-12T05:18:51Z","lastAt":"2011-02-12T07:43:50Z","messageCount":2,"participants":["Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"160931","messageId":"20110212051850.GA715@sigill.intra.peff.net","threadId":"26478","inReplyTo":null,"subject":"[PATCH] string_list_append: always set util pointer to NULL","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-02-12T05:18:51Z","receivedAt":"2011-02-12T05:18:51Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"It is not immediately obvious that the util field may\ncontain random bytes after appending an item. Especially\nsince the string_list_insert* functions _do_ explicitly zero\nthe util pointer.\n\nThis does not appear to be a bug in any current git code, as\nall callers either fill in the util field immediately or\nnever use it. However, it is worth it to be less surprising\nto new users of the string-list API who may expect it to be\nintialized to NULL.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nThis bit me in some new code I was writing. I consider it a bug fix, but\neven if you don't, I think it is still an API improvement. :)\n\n string-list.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/string-list.c b/string-list.c\nindex 9b023a2..5168118 100644\n--- a/string-list.c\n+++ b/string-list.c\n@@ -153,6 +153,7 @@ struct string_list_item *string_list_append(struct string_list *list, const char\n \tALLOC_GROW(list->items, list->nr + 1, list->alloc);\n \tlist->items[list->nr].string =\n \t\tlist->strdup_strings ? xstrdup(string) : (char *)string;\n+\tlist->items[list->nr].util = NULL;\n \treturn list->items + list->nr++;\n }\n \n-- \n1.7.4\n"},{"id":"160934","messageId":"7v4o89zoi1.fsf@alter.siamese.dyndns.org","threadId":"26478","inReplyTo":"20110212051850.GA715@sigill.intra.peff.net","subject":"Re: [PATCH] string_list_append: always set util pointer to NULL","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-02-12T07:43:50Z","receivedAt":"2011-02-12T07:43:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> It is not immediately obvious that the util field may\n> contain random bytes after appending an item. Especially\n> since the string_list_insert* functions _do_ explicitly zero\n> the util pointer.\n>\n> This does not appear to be a bug in any current git code, as\n> all callers either fill in the util field immediately or\n> never use it. However, it is worth it to be less surprising\n> to new users of the string-list API who may expect it to be\n> intialized to NULL.\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> This bit me in some new code I was writing. I consider it a bug fix, but ...\n\nOf course; the \"Especially since\" part is very convincing.\n"}]}