mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-25 20:50:25 +01:00
mempool: Reduce an assert into an error return for get_buddy()
If we ask for a buddy that is outside of our allocation that is an error that should not happen with a power-of-two allocated zone... However, since it has been seen in the wild, we can safely return that there is no buddy rather than die in a too-late assert. Reported-by: Anton Eliasson <devel@antoneliasson.se> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
2c2dccf5a4
commit
01a8bf01c6
1 changed files with 2 additions and 1 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue