diff options
author | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2015-03-13 00:27:19 +0000 |
---|---|---|
committer | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2015-03-13 00:27:19 +0000 |
commit | 8a53799a0ffb7ca5bdcb457e7104e971c79b0d4e (patch) | |
tree | af242da25c2bb5a706d9dc38363c418e1178625d /poll/unix/epoll.c | |
parent | 1161cd835c13304474c4c4e0ebf0ea71ac15a413 (diff) | |
download | libapr-8a53799a0ffb7ca5bdcb457e7104e971c79b0d4e.tar.gz |
apr_poll(cb): fix error paths returned values and leaks.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1666341 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poll/unix/epoll.c')
-rw-r--r-- | poll/unix/epoll.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/poll/unix/epoll.c b/poll/unix/epoll.c index 965e2833c..23686d5f5 100644 --- a/poll/unix/epoll.c +++ b/poll/unix/epoll.c @@ -106,12 +106,20 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset, { int fd_flags; - if ((fd_flags = fcntl(fd, F_GETFD)) == -1) - return errno; + if ((fd_flags = fcntl(fd, F_GETFD)) == -1) { + rv = errno; + close(fd); + pollset->p = NULL; + return rv; + } fd_flags |= FD_CLOEXEC; - if (fcntl(fd, F_SETFD, fd_flags) == -1) - return errno; + if (fcntl(fd, F_SETFD, fd_flags) == -1) { + rv = errno; + close(fd); + pollset->p = NULL; + return rv; + } } #endif @@ -122,11 +130,13 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset, ((rv = apr_thread_mutex_create(&pollset->p->ring_lock, APR_THREAD_MUTEX_DEFAULT, p)) != APR_SUCCESS)) { + close(fd); pollset->p = NULL; return rv; } #else if (flags & APR_POLLSET_THREADSAFE) { + close(fd); pollset->p = NULL; return APR_ENOTIMPL; } @@ -347,13 +357,22 @@ static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb, #ifndef HAVE_EPOLL_CREATE1 { int fd_flags; + apr_status_t rv; - if ((fd_flags = fcntl(fd, F_GETFD)) == -1) - return errno; + if ((fd_flags = fcntl(fd, F_GETFD)) == -1) { + rv = errno; + close(fd); + pollcb->fd = -1; + return rv; + } fd_flags |= FD_CLOEXEC; - if (fcntl(fd, F_SETFD, fd_flags) == -1) - return errno; + if (fcntl(fd, F_SETFD, fd_flags) == -1) { + rv = errno; + close(fd); + pollcb->fd = -1; + return rv; + } } #endif |