mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 12:28:19 -04:00
epoll: close fd on alloc fail at initialization
If the memory allocations fail then we free any other allocated structures but don't close the file descriptor resulting in an leak of fd's.
This commit is contained in:
parent
3c824bd334
commit
1aee718362
5
epoll.c
5
epoll.c
@ -120,8 +120,10 @@ epoll_init(struct event_base *base)
|
||||
|
||||
evutil_make_socket_closeonexec(epfd);
|
||||
|
||||
if (!(epollop = mm_calloc(1, sizeof(struct epollop))))
|
||||
if (!(epollop = mm_calloc(1, sizeof(struct epollop)))) {
|
||||
close(epfd);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
epollop->epfd = epfd;
|
||||
|
||||
@ -129,6 +131,7 @@ epoll_init(struct event_base *base)
|
||||
epollop->events = mm_calloc(INITIAL_NEVENT, sizeof(struct epoll_event));
|
||||
if (epollop->events == NULL) {
|
||||
mm_free(epollop);
|
||||
close(epfd);
|
||||
return (NULL);
|
||||
}
|
||||
epollop->nevents = INITIAL_NEVENT;
|
||||
|
Loading…
x
Reference in New Issue
Block a user