summaryrefslogtreecommitdiff
path: root/network_io
diff options
context:
space:
mode:
authorylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2015-03-20 01:31:17 +0000
committerylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2015-03-20 01:31:17 +0000
commitb55b9cf0def0896b8e812e0e66b160e39ca6d788 (patch)
treec03330d25566f6fcac26bb2feff35c938a6bc308 /network_io
parentb1fd5ae791879d5abaf8b331771fe63f27598f61 (diff)
downloadlibapr-b55b9cf0def0896b8e812e0e66b160e39ca6d788.tar.gz
Merge r1666341, r1667914 and r1667916 from trunk.
apr_poll(cb): fix error paths returned values and leaks. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1667919 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r--network_io/unix/sockets.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c
index c38e6a656..206c65447 100644
--- a/network_io/unix/sockets.c
+++ b/network_io/unix/sockets.c
@@ -175,13 +175,22 @@ apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type,
#ifndef HAVE_SOCK_CLOEXEC
{
int flags;
+ apr_status_t rv;
- if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
- return errno;
+ if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) {
+ rv = errno;
+ close((*new)->socketdes);
+ (*new)->socketdes = -1;
+ return rv;
+ }
flags |= FD_CLOEXEC;
- if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
- return errno;
+ if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) {
+ rv = errno;
+ close((*new)->socketdes);
+ (*new)->socketdes = -1;
+ return rv;
+ }
}
#endif
@@ -351,13 +360,22 @@ apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock,
#ifndef HAVE_ACCEPT4
{
int flags;
+ apr_status_t rv;
- if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
- return errno;
+ if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) {
+ rv = errno;
+ close((*new)->socketdes);
+ (*new)->socketdes = -1;
+ return rv;
+ }
flags |= FD_CLOEXEC;
- if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
- return errno;
+ if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) {
+ rv = errno;
+ close((*new)->socketdes);
+ (*new)->socketdes = -1;
+ return rv;
+ }
}
#endif