]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sign-compare: avoid comparing ptrdiff with an int/unsigned
authorJunio C Hamano <gitster@pobox.com>
Fri, 27 Dec 2024 20:25:30 +0000 (12:25 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Dec 2024 20:25:30 +0000 (12:25 -0800)
Instead, offset the base pointer with integer and compare it with
the other pointer.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
shallow.c

index b8fcfbef0f9cdbfa895d4d6e1214f67942f88d25..b54244ffa90d66a35fef51f2ac8d5ab8144fa9b8 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -534,7 +534,7 @@ static uint32_t *paint_alloc(struct paint_info *info)
        unsigned nr = DIV_ROUND_UP(info->nr_bits, 32);
        unsigned size = nr * sizeof(uint32_t);
        void *p;
-       if (!info->pool_count || size > info->end - info->free) {
+       if (!info->pool_count || info->end < info->free + size) {
                if (size > POOL_SIZE)
                        BUG("pool size too small for %d in paint_alloc()",
                            size);