]> git.ipfire.org Git - thirdparty/git.git/commitdiff
string_list_append: always set util pointer to NULL
authorJeff King <peff@peff.net>
Sat, 12 Feb 2011 05:18:51 +0000 (00:18 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 14 Feb 2011 18:55:03 +0000 (10:55 -0800)
It is not immediately obvious that the util field may
contain random bytes after appending an item. Especially
since the string_list_insert* functions _do_ explicitly zero
the util pointer.

This does not appear to be a bug in any current git code, as
all callers either fill in the util field immediately or
never use it. However, it is worth it to be less surprising
to new users of the string-list API who may expect it to be
intialized to NULL.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
string-list.c

index 9b023a25841cb7a9c1faecc30c484eba0e16d6af..51681189e8380cc43ed26d35526a6dff78f1a24c 100644 (file)
@@ -153,6 +153,7 @@ struct string_list_item *string_list_append(struct string_list *list, const char
        ALLOC_GROW(list->items, list->nr + 1, list->alloc);
        list->items[list->nr].string =
                list->strdup_strings ? xstrdup(string) : (char *)string;
+       list->items[list->nr].util = NULL;
        return list->items + list->nr++;
 }