]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: widen `deflate_it()`'s bound local from int to `size_t`
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 9 Jul 2026 16:49:36 +0000 (16:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Jul 2026 21:55:24 +0000 (14:55 -0700)
Fixes a pre-existing silent narrowing from `git_deflate_bound()`'s
`unsigned long` return into an `int` local: anything past 2 GiB has
always wrapped negative here and then been re-extended to `size_t`
inside `xmalloc()`. Also prep for the upcoming `git_deflate_bound()`
widening to `size_t`, which would extend the narrowing further if
`bound` stayed `int`.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c

diff --git a/diff.c b/diff.c
index 69eb2f76a4e51cec44190ea199bdde107328394d..c14f69719bd8528f32be5e4c845b19a08847160e 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -3609,7 +3609,7 @@ static unsigned char *deflate_it(char *data,
                                 unsigned long size,
                                 unsigned long *result_size)
 {
-       int bound;
+       size_t bound;
        unsigned char *deflated;
        git_zstream stream;
        struct repo_config_values *cfg = repo_config_values(the_repository);