Browse Source

HPCC-10552 Close a couple of sockets in error situations

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 11 years ago
parent
commit
dfd477e092
1 changed files with 7 additions and 1 deletions
  1. 7 1
      system/jlib/jsocket.cpp

+ 7 - 1
system/jlib/jsocket.cpp

@@ -2525,7 +2525,10 @@ bool isInterfaceIp(const IpAddress &ip, const char *ifname)
     ifc.ifc_len = 1024;
     ifc.ifc_buf = buf;
     if(ioctl(fd, SIOCGIFCONF, &ifc) < 0) // query interfaces
+    {
+        close(fd);
         return false;
+    }
     struct ifreq *ifr = ifc.ifc_req;
     unsigned n = ifc.ifc_len/sizeof(struct ifreq);
     bool match = false;
@@ -2562,7 +2565,10 @@ bool getInterfaceIp(IpAddress &ip,const char *ifname)
     ifc.ifc_len = 1024;
     ifc.ifc_buf = buf;
     if(ioctl(fd, SIOCGIFCONF, &ifc) < 0) // query interfaces
+    {
+        close(fd);
         return false;
+    }
     struct ifreq *ifr = ifc.ifc_req;
     unsigned n = ifc.ifc_len/sizeof(struct ifreq);
     for (int loopback = 0; loopback <= 1; loopback++)
@@ -5385,8 +5391,8 @@ void multiConnect(const SocketEndpointArray &eps,ISocketConnectNotify &inotify,u
                     break;
             }
         }
-        delete [] elems;
     }
+    delete [] elems;
 }
 
 void multiConnect(const SocketEndpointArray &eps, PointerIArrayOf<ISocket> &retsockets,unsigned timeout)