mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-03 09:01:42 -05:00
shm: add safety assertions
Catch any API mis-use with an assert. This should abort when the user calls unreferences the pool more times than it's referenced. Also change the refcount check to explicitly check for positive counts. That makes the condition more readable. Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
ccc9612e82
commit
817fdb9009
1 changed files with 3 additions and 1 deletions
|
|
@ -106,13 +106,15 @@ shm_pool_unref(struct wl_shm_pool *pool, bool external)
|
|||
{
|
||||
if (external) {
|
||||
pool->external_refcount--;
|
||||
assert(pool->external_refcount >= 0);
|
||||
if (pool->external_refcount == 0)
|
||||
shm_pool_finish_resize(pool);
|
||||
} else {
|
||||
pool->internal_refcount--;
|
||||
assert(pool->internal_refcount >= 0);
|
||||
}
|
||||
|
||||
if (pool->internal_refcount + pool->external_refcount)
|
||||
if (pool->internal_refcount + pool->external_refcount > 0)
|
||||
return;
|
||||
|
||||
munmap(pool->data, pool->size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue