libweston: Assert if ref-count balance is wrong

Calling weston_surface_unref() one time too many could be a sign we
haven't correctly increased the ref count for it.

Also, if we don't have a surface being passed, do no attempt to
use it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad
2022-02-07 11:05:14 +02:00
parent 0d8e94af61
commit d3ed2eb345
+4
View File
@@ -2303,6 +2303,10 @@ weston_surface_unref(struct weston_surface *surface)
struct weston_pointer_constraint *constraint, *next_constraint;
struct weston_paint_node *pnode, *pntmp;
if (!surface)
return;
assert(surface->ref_count > 0);
if (--surface->ref_count > 0)
return;