From 85e3967b6760964878004bcfbbe9b1db3063e17c Mon Sep 17 00:00:00 2001 From: Arusekk Date: Mon, 12 Jan 2026 16:44:10 +0100 Subject: [PATCH] do not crash on kernels without CONFIG_MEMFD_CREATE --- frontends/tiny/wl.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/frontends/tiny/wl.c b/frontends/tiny/wl.c index a6664b124..dc24e50ae 100644 --- a/frontends/tiny/wl.c +++ b/frontends/tiny/wl.c @@ -653,6 +653,22 @@ redraw(void *data) pixman_region32_clear(&p->damage); } +static int +memfd(void) +{ + int fd; + char template[] = "/tmp/netsurf-XXXXXX"; + + fd = syscall(SYS_memfd_create, "netsurf", 0); + if (fd >= 0) + return fd; + fd = mkstemp(template); + if (fd < 0) + return fd; + (void)unlink(template); + return fd; +} + static struct wlimage * createimage(int w, int h) { @@ -665,7 +681,7 @@ createimage(int w, int h) goto err0; stride = w * 4; i->size = h * stride; - fd = syscall(SYS_memfd_create, "netsurf", 0); + fd = memfd(); if (fd < 0) goto err1; if (posix_fallocate(fd, 0, i->size) < 0)