summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2013-03-07 23:32:39 +0100
committerKristian Høgsberg <krh@bitplanet.net>2013-03-21 12:28:56 -0400
commitdaa4e43b30c09d5a3fbcd7eed6b2c98c84a1d37f (patch)
treed6eb498df56d738881c447074ee64cf169f28bb8
parentconfigure.ac: Use wayland_version macro in bug url (diff)
downloadwayland-daa4e43b30c09d5a3fbcd7eed6b2c98c84a1d37f.tar
wayland-daa4e43b30c09d5a3fbcd7eed6b2c98c84a1d37f.tar.gz
wayland-daa4e43b30c09d5a3fbcd7eed6b2c98c84a1d37f.tar.bz2
wayland-daa4e43b30c09d5a3fbcd7eed6b2c98c84a1d37f.tar.lz
wayland-daa4e43b30c09d5a3fbcd7eed6b2c98c84a1d37f.tar.xz
wayland-daa4e43b30c09d5a3fbcd7eed6b2c98c84a1d37f.tar.zst
wayland-daa4e43b30c09d5a3fbcd7eed6b2c98c84a1d37f.zip
client: Check reference count only for destroyed proxies
The llvm static analyzer tool reported "Use of memory after it is freed" in dispatch_event() because the proxy is used after being freed if the reference count reaches zero without the destroyed flag being set. This would never happen in practice because the owner of the proxy object always holds a reference until calling wl_proxy_destroy() which would also set the destroyed flag. Since this is the case, it is safe to do the reference count check only if the destroyed flag is set, as it can never reach zero if not. This commit doesn't change the behavior of the function, but makes the static analyzer more happy. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=61385 Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
-rw-r--r--src/wayland-client.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wayland-client.c b/src/wayland-client.c
index 74e4657..3ead2ac 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -822,10 +822,10 @@ dispatch_event(struct wl_display *display, struct wl_event_queue *queue)
proxy_destroyed = !!(proxy->flags & WL_PROXY_FLAG_DESTROYED);
proxy->refcount--;
- if (!proxy->refcount)
- free(proxy);
-
if (proxy_destroyed) {
+ if (!proxy->refcount)
+ free(proxy);
+
wl_closure_destroy(closure);
return;
}