mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
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
This commit is contained in:
parent
06214b6087
commit
ecac86b0ca
1 changed files with 8 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue