diff --git a/shallow.c b/shallow.c index 7d5ea0cd39..4c4486ad67 100644 --- a/shallow.c +++ b/shallow.c @@ -368,7 +368,7 @@ static uint32_t *paint_alloc(struct paint_info *info) unsigned nr = (info->nr_bits + 31) / 32; unsigned size = nr * sizeof(uint32_t); void *p; - if (!info->pool_count || info->free + size > info->end) { + if (!info->pool_count || size > info->end - info->free) { if (size > POOL_SIZE) die("BUG: pool size too small for %d in paint_alloc()", size);