Skip to content

Commit 3361390

Browse files
peffgitster
authored andcommitted
commit-graph: use size_t for array allocation and indexing
Our packed_commit_list is an array of pointers to commit structs. We use "int" for the allocation, which is 32-bit even on 64-bit platforms. This isn't likely to overflow in practice (we're writing commit graphs, so you'd need to actually have billions of unique commits in the repository). But it's good practice to use size_t for allocations. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5f1c44 commit 3361390

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

commit-graph.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,8 @@ struct tree *get_commit_tree_in_graph(struct repository *r, const struct commit
932932

933933
struct packed_commit_list {
934934
struct commit **list;
935-
int nr;
936-
int alloc;
935+
size_t nr;
936+
size_t alloc;
937937
};
938938

939939
struct write_commit_graph_context {

0 commit comments

Comments
 (0)