Files
RedBear-OS/local/patches/libwayland/redox.patch
T

102 lines
2.9 KiB
Diff

--- a/src/wayland-client.c.orig
+++ b/src/wayland-client.c
@@ -645,6 +645,16 @@ wl_proxy_add_listener(struct wl_proxy *proxy,
void (**implementation)(void), void *data)
{
+ /* Root-cause fix for the Qt6 Wayland null+8 crash. When the
+ * upstream proxy is NULL (e.g. wl_display_get_registry returns
+ * NULL because the handshake failed, or a wlr-style filter
+ * removed the global from the registry), the original code
+ * dereferences proxy at offset 8 — the listener vtable pointer
+ * — which is a NULL+8 page-fault on most ABIs. Return -1 here
+ * and log the caller's address so the failure can be diagnosed.
+ * Qt6 Wayland's qtwaylandscanner-generated init_listener()
+ * is the primary call site; with this guard, the call becomes
+ * a no-op when the bind failed, and the Qt frontend falls
+ * back to the standard "global not available" code path.
+ */
+ if (!proxy) {
+ fprintf(stderr,
+ "FATAL: wl_proxy_add_listener(NULL proxy) caller=%p -- returning error\n",
+ __builtin_return_address(0));
+ errno = EINVAL;
+ return -1;
+ }
if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
wl_abort("Proxy %p is a wrapper\n", proxy);
@@ -2452,6 +2462,16 @@ WL_EXPORT uint32_t
WL_EXPORT uint32_t
wl_proxy_get_version(struct wl_proxy *proxy)
{
+ if (!proxy) {
+ errno = EINVAL;
+ return 0;
+ }
if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
return proxy->version;
@@ -2470,6 +2490,16 @@ WL_EXPORT void
wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data)
{
+ if (!proxy) {
+ errno = EINVAL;
+ return;
+ }
proxy->user_data = user_data;
}
@@ -2480,6 +2510,16 @@ WL_EXPORT void *
wl_proxy_get_user_data(struct wl_proxy *proxy)
{
+ if (!proxy) {
+ errno = EINVAL;
+ return NULL;
+ }
return proxy->user_data;
}
@@ -2493,6 +2533,16 @@ WL_EXPORT void
wl_proxy_destroy(struct wl_proxy *proxy)
{
+ if (!proxy) {
+ return;
+ }
wl_proxy_destroy_common(proxy, 0);
}
--- a/src/wayland-server.c.orig
+++ b/src/wayland-server.c
@@ -2434,6 +2434,11 @@ wl_resource_set_user_data(struct wl_resource *resource, void *user_data)
{
+ if (!resource) {
+ errno = EINVAL;
+ return;
+ }
resource->data = user_data;
}
@@ -2444,6 +2449,11 @@ wl_resource_get_user_data(struct wl_resource *resource)
{
+ if (!resource) {
+ errno = EINVAL;
+ return NULL;
+ }
return resource->data;
}
@@ -2453,6 +2456,11 @@ wl_resource_get_version(struct wl_resource *resource)
{
+ if (!resource) {
+ errno = EINVAL;
+ return 0;
+ }
return resource->version;
}
--- a/src/meson.build.orig
+++ b/src/meson.build
@@ -81,8 +81,7 @@ endif
if meson.is_cross_build() or not get_option('scanner')
- scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
- wayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))
+ wayland_scanner_for_build = find_program('wayland-scanner', native: true)
else
wayland_scanner_for_build = wayland_scanner
endif