Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 <>
Signed-off-by: Junio C Hamano <>
  • Loading branch information...
commit 62b8102c60a716e66cfd2a33e596e9d5be134267 1 parent dab0d41
Jeff King authored February 12, 2011 gitster committed February 14, 2011

Showing 1 changed file with 1 addition and 0 deletions. Show diff stats Hide diff stats

  1. 1  string-list.c
1  string-list.c
@@ -153,6 +153,7 @@ struct string_list_item *string_list_append(struct string_list *list, const char
153 153
 	ALLOC_GROW(list->items, list->nr + 1, list->alloc);
154 154
 	list->items[list->nr].string =
155 155
 		list->strdup_strings ? xstrdup(string) : (char *)string;
+	list->items[list->nr].util = NULL;
156 157
 	return list->items + list->nr++;
157 158
158 159

0 notes on commit 62b8102

Please sign in to comment.
Something went wrong with that request. Please try again.