Files
RedBear-OS/local/patches/libwayland/redox.patch
T
vasilito 9f19ecf7b6 fix: libwayland null guards made durable — appended to redox.patch
Three null-safety additions to wayland-client.c, now in the recipe's
redox.patch so they survive source rebuilds:
- wl_proxy_add_listener: return -1 on NULL (prevents null+8 page fault)
- wl_proxy_get_version: return 0 on NULL
- wl_proxy_get_display: return NULL on NULL
2026-05-06 13:44:57 +01:00

67 lines
1.9 KiB
Diff

--- a/src/meson.build
+++ 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
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -39,7 +39,23 @@
#include <dlfcn.h>
#include <sys/time.h>
#include <fcntl.h>
-#include <sys/eventfd.h>
+#ifndef EFD_CLOEXEC
+#define EFD_CLOEXEC O_CLOEXEC
+#endif
+#ifndef EFD_NONBLOCK
+#define EFD_NONBLOCK O_NONBLOCK
+#endif
+#ifndef EFD_SEMAPHORE
+#define EFD_SEMAPHORE 0x1
+#endif
+static int eventfd(unsigned int initval, int flags) {
+ int oflag = O_RDWR;
+ if (flags & EFD_CLOEXEC) oflag |= O_CLOEXEC;
+ if (flags & EFD_NONBLOCK) oflag |= O_NONBLOCK;
+ char path[64];
+ snprintf(path, sizeof(path), "/scheme/event/eventfd/%u/%d", initval, (flags & EFD_SEMAPHORE) ? 1 : 0);
+ return open(path, oflag);
+}
#include <sys/file.h>
#include <sys/stat.h>
+--- a/src/wayland-client.c
++++ b/src/wayland-client.c
+@@ -649,6 +649,11 @@
+ wl_proxy_add_listener(struct wl_proxy *proxy,
+ void (**implementation)(void), void *data)
+ {
++ if (!proxy) {
++ 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);
+
+@@ -2448,6 +2453,7 @@
+ wl_proxy_get_version(struct wl_proxy *proxy)
+ {
++ if (!proxy) return 0;
+ return proxy->version;
+ }
+
+@@ -2566,6 +2572,7 @@
+ wl_proxy_get_display(struct wl_proxy *proxy)
+ {
++ if (!proxy) return NULL;
+ return proxy->display;
+ }