From d3ed2eb34533e901f4d02c45058318bc3f922cb2 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Mon, 7 Feb 2022 11:05:14 +0200 Subject: [PATCH] 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 --- libweston/compositor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libweston/compositor.c b/libweston/compositor.c index 91425fb1..fe92a462 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -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;