Hi,
I have found a couple of memory leaks in the error management code of the epoll init function.
This patch fixes them.
Best regards.
P.S: Keep up the good work
--- cherokee-0.4.20.old/cherokee/fdpoll-epoll.c 2005-04-22 18:29:24.000000000 +0100
+++ cherokee-0.4.20/cherokee/fdpoll-epoll.c 2005-05-05 15:38:09.811503000 +0100
@@ -279,13 +279,16 @@
n->epoll_rs2idx = (int *) malloc (sizeof(int) * nfd->system_nfiles);
n->epoll_idx2rs = (int *) malloc (sizeof(int) * nfd->system_nfiles);
+ /* If anyone fails free all and return ret_nomem
+ */
+ if ( (!n->ep_events ) || (!n->epoll_rs2idx) || (!n->epoll_idx2rs) ) {
+ _free( nfd );
+ return ret_nomem;
+ }
+
memset (n->epoll_rs2idx, -1, nfd->system_nfiles);
memset (n->epoll_idx2rs, -1, nfd->system_nfiles);
- return_if_fail (n->ep_events, ret_nomem);
- return_if_fail (n->epoll_rs2idx, ret_nomem);
- return_if_fail (n->epoll_idx2rs, ret_nomem);
-
n->ep_fd = epoll_create (nfd->nfiles + 1);
if (n->ep_fd < 0) {
/* It might fail here if the glibc library supports epoll, but the kernel doesn't.
@@ -294,6 +297,7 @@
PRINT_ERROR ("ERROR: Couldn't get epoll descriptor: epoll_create(%d): %s\n",
nfd->nfiles+1, strerror(errno));
#endif
+ _free( nfd );
return ret_error;
}
@@ -301,8 +305,7 @@
if (re < 0) {
PRINT_ERROR ("ERROR: Couldn't set CloseExec to the epoll descriptor: fcntl: %s\n",
strerror(errno));
- close (n->ep_fd);
- n->ep_fd = -1;
+ _free( nfd );
return ret_error;
}
_______________________________________________ Cherokee mailing list [email protected] http://www.alobbs.com/cgi-bin/mailman/listinfo/cherokee
