https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/636cbae9b6cebc4ba55903e2a686f4c4a2bd4193

From 636cbae9b6cebc4ba55903e2a686f4c4a2bd4193 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Fri, 26 Sep 2025 10:52:40 +0200
Subject: [PATCH] avahi: handle fd allocation errors

When we fail to allocate an io source or a timerfd, return NULL instead
of crashing later on.

See #4913
---
 src/modules/module-zeroconf-discover/avahi-poll.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/modules/module-zeroconf-discover/avahi-poll.c b/src/modules/module-zeroconf-discover/avahi-poll.c
index ab54888f65..65b64736af 100644
--- a/src/modules/module-zeroconf-discover/avahi-poll.c
+++ b/src/modules/module-zeroconf-discover/avahi-poll.c
@@ -72,7 +72,10 @@ static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event
 	w->userdata = userdata;
 	w->source = pw_loop_add_io(impl->loop, fd, to_pw_events(event),
 			false, watch_callback, w);
-
+	if (w->source == NULL) {
+		free(w);
+		return NULL;
+	}
 	return w;
 }
 
@@ -117,7 +120,10 @@ static AvahiTimeout* timeout_new(const AvahiPoll *api, const struct timeval *tv,
 	w->callback = callback;
 	w->userdata = userdata;
 	w->source = pw_loop_add_timer(impl->loop, timeout_callback, w);
-
+	if (w->source == NULL) {
+		free(w);
+		return NULL;
+	}
 	if (tv != NULL) {
 		value.tv_sec = tv->tv_sec;
 		value.tv_nsec = tv->tv_usec * 1000UL;
-- 
GitLab
