Skip to content

Commit 43a2dfd

Browse files
mhaggergitster
authored andcommitted
refs: use size_t indexes when iterating over ref transaction updates
Eliminate any chance of integer overflow on platforms where the two types have different sizes. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c759971 commit 43a2dfd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err)
848848

849849
void ref_transaction_free(struct ref_transaction *transaction)
850850
{
851-
int i;
851+
size_t i;
852852

853853
if (!transaction)
854854
return;

refs/files-backend.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,7 +2850,8 @@ static int files_transaction_commit(struct ref_store *ref_store,
28502850
struct files_ref_store *refs =
28512851
files_downcast(ref_store, REF_STORE_WRITE,
28522852
"ref_transaction_commit");
2853-
int ret = 0, i;
2853+
size_t i;
2854+
int ret = 0;
28542855
struct string_list refs_to_delete = STRING_LIST_INIT_NODUP;
28552856
struct string_list_item *ref_to_delete;
28562857
struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
@@ -3057,7 +3058,8 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,
30573058
struct files_ref_store *refs =
30583059
files_downcast(ref_store, REF_STORE_WRITE,
30593060
"initial_ref_transaction_commit");
3060-
int ret = 0, i;
3061+
size_t i;
3062+
int ret = 0;
30613063
struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
30623064

30633065
assert(err);

0 commit comments

Comments
 (0)