Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
string_list_append: always set util pointer to NULL
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Feb 14, 2011
1 parent dab0d41 commit 62b8102
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions string-list.c
Expand Up @@ -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++;
}

Expand Down

0 comments on commit 62b8102

Please sign in to comment.