Skip to content

Commit 62b8102

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dab0d41 commit 62b8102

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

string-list.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ struct string_list_item *string_list_append(struct string_list *list, const char
153153
ALLOC_GROW(list->items, list->nr + 1, list->alloc);
154154
list->items[list->nr].string =
155155
list->strdup_strings ? xstrdup(string) : (char *)string;
156+
list->items[list->nr].util = NULL;
156157
return list->items + list->nr++;
157158
}
158159

0 commit comments

Comments
 (0)