modules: avoid some leaks in error paths

This commit is contained in:
Wim Taymans 2023-03-16 11:44:56 +01:00
parent 1985eb3549
commit 79b6dab5f9
2 changed files with 27 additions and 12 deletions

View file

@ -1158,6 +1158,7 @@ static int make_socket(const struct sockaddr_storage* sa, socklen_t salen,
return fd;
error:
close(fd);
return res;
}
@ -1172,8 +1173,10 @@ static int setup_apple_session(struct impl *impl)
impl->ctrl_source = pw_loop_add_io(impl->loop, fd,
SPA_IO_IN, true, on_ctrl_io, impl);
if (impl->ctrl_source == NULL)
if (impl->ctrl_source == NULL) {
close(fd);
return -errno;
}
if ((fd = make_socket(&impl->data_addr, impl->data_len,
impl->mcast_loop, impl->ttl, impl->ifname)) < 0)
@ -1181,9 +1184,10 @@ static int setup_apple_session(struct impl *impl)
impl->data_source = pw_loop_add_io(impl->data_loop, fd,
SPA_IO_IN, true, on_data_io, impl);
if (impl->data_source == NULL)
if (impl->data_source == NULL) {
close(fd);
return -errno;
}
return 0;
}