diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c index d317c5e..5b4a43d 100644 --- a/src/egl/wayland/wayland-drm/wayland-drm.c +++ b/src/egl/wayland/wayland-drm/wayland-drm.c @@ -87,6 +87,7 @@ create_buffer(struct wl_client *client, struct wl_resource *resource, return; } + buffer->magic = DRM_BUFFER_MAGIC; buffer->drm = drm; buffer->width = width; buffer->height = height; @@ -245,12 +246,14 @@ bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id) struct wl_drm_buffer * wayland_drm_buffer_get(struct wl_resource *resource) { + struct wl_drm_buffer *buffer; + if (resource == NULL) return NULL; - if (wl_resource_instance_of(resource, &wl_buffer_interface, - &drm_buffer_interface)) - return wl_resource_get_user_data(resource); + buffer = wl_resource_get_user_data(resource); + if (buffer->magic == DRM_BUFFER_MAGIC) + return buffer; else return NULL; } diff --git a/src/egl/wayland/wayland-drm/wayland-drm.h b/src/egl/wayland/wayland-drm/wayland-drm.h index ca04882..45da8c4 100644 --- a/src/egl/wayland/wayland-drm/wayland-drm.h +++ b/src/egl/wayland/wayland-drm/wayland-drm.h @@ -69,7 +69,10 @@ enum wl_drm_format { struct wl_drm; +#define DRM_BUFFER_MAGIC 0x1164726d + struct wl_drm_buffer { + uint32_t magic; struct wl_resource *resource; struct wl_drm *drm; int32_t width, height;