diff --git a/src/cairo-mempool.c b/src/cairo-mempool.c index 96e4a62b2..751ede320 100644 --- a/src/cairo-mempool.c +++ b/src/cairo-mempool.c @@ -157,7 +157,8 @@ get_buddy (cairo_mempool_t *pool, size_t offset, int bits) { struct _cairo_memblock *block; - assert (offset + (1 << bits) <= pool->num_blocks); + if (offset + (1 << bits) >= pool->num_blocks) + return NULL; /* invalid */ if (BITTEST (pool, offset + (1 << bits) - 1)) return NULL; /* buddy is allocated */