From 3afed4364790aebe0426077631af1e164a9650cc Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 18 May 2024 19:52:55 +0100 Subject: [PATCH] core: avoid uaf in resource_set_user_data --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 9b9ef95..654e2d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -723,11 +723,12 @@ const wl_interface {} = {{ wl_list_remove(&resourceDestroyListener.link); wl_list_init(&resourceDestroyListener.link); + wl_resource_set_user_data(pResource, nullptr); + // if we still own the wayland resource, // it means we need to destroy it. if (wl_resource_get_user_data(pResource) == this) wl_resource_destroy(pResource); - wl_resource_set_user_data(pResource, nullptr); }} void {}::onDestroyCalled() {{