diff options
| author | Simon Ser <contact@emersion.fr> | 2019-07-22 19:41:22 +0300 |
|---|---|---|
| committer | Pekka Paalanen <pq@iki.fi> | 2019-09-27 09:14:52 +0000 |
| commit | d5055ad913f4913c1bb1c17cef55049e30c191ad (patch) | |
| tree | 00271f93b84f2a1acdabdee1f2e56a2336349717 /src | |
| parent | Add $(RT_LIBS) to fixed-benchmark LD dependencies (diff) | |
| download | wayland-d5055ad913f4913c1bb1c17cef55049e30c191ad.tar wayland-d5055ad913f4913c1bb1c17cef55049e30c191ad.tar.gz wayland-d5055ad913f4913c1bb1c17cef55049e30c191ad.tar.bz2 wayland-d5055ad913f4913c1bb1c17cef55049e30c191ad.tar.lz wayland-d5055ad913f4913c1bb1c17cef55049e30c191ad.tar.xz wayland-d5055ad913f4913c1bb1c17cef55049e30c191ad.tar.zst wayland-d5055ad913f4913c1bb1c17cef55049e30c191ad.zip | |
server: add wl_global_set_user_data
When implementing a workaround for [1], one needs to accept a global to be
bound even though it has become stale.
Often, a global's user data is free'd when the global needs to be destroyed.
Being able to set the global's user data (e.g. to NULL) can help preventing a
use-after-free.
(The alternative is to make the compositor responsible for keeping track of
stale user data objects via e.g. refcounting.)
[1]: https://gitlab.freedesktop.org/wayland/wayland/issues/10
Signed-off-by: Simon Ser <contact@emersion.fr>
Diffstat (limited to 'src')
| -rw-r--r-- | src/wayland-server-core.h | 3 | ||||
| -rw-r--r-- | src/wayland-server.c | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h index 3e0272b..68d7ddb 100644 --- a/src/wayland-server-core.h +++ b/src/wayland-server-core.h @@ -279,6 +279,9 @@ wl_global_get_interface(const struct wl_global *global); void * wl_global_get_user_data(const struct wl_global *global); +void +wl_global_set_user_data(struct wl_global *global, void *data); + struct wl_client * wl_client_create(struct wl_display *display, int fd); diff --git a/src/wayland-server.c b/src/wayland-server.c index 11cb7f5..8c537bb 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -1245,6 +1245,19 @@ wl_global_get_user_data(const struct wl_global *global) return global->data; } +/** Set the global's user data + * + * \param global The global object + * \param data The user data pointer + * + * \since 1.17.90 + */ +WL_EXPORT void +wl_global_set_user_data(struct wl_global *global, void *data) +{ + global->data = data; +} + /** Get the current serial number * * \param display The display object |
