coverity#1371380 Resource leak on an exceptional path
Change-Id: I278f8d50dfaaa45e582a34e43ddba3b143203796
This commit is contained in:
@@ -144,7 +144,7 @@ public final class socketAcceptor implements XAcceptor {
|
||||
}
|
||||
serv = server;
|
||||
}
|
||||
Socket socket;
|
||||
Socket socket = null;
|
||||
try {
|
||||
socket = serv.accept();
|
||||
if (DEBUG) {
|
||||
@@ -165,6 +165,12 @@ public final class socketAcceptor implements XAcceptor {
|
||||
return new SocketConnection(acceptingDescription, socket);
|
||||
}
|
||||
catch(IOException e) {
|
||||
if (socket != null) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch(IOException ioException) {
|
||||
}
|
||||
}
|
||||
throw new ConnectionSetupException(e);
|
||||
}
|
||||
}
|
||||
|
@@ -154,9 +154,11 @@ public final class socketConnector implements XConnector {
|
||||
|
||||
con = new SocketConnection(connectionDescription, socket);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch(IOException ioException) {
|
||||
if (socket != null) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch(IOException ioException) {
|
||||
}
|
||||
}
|
||||
throw new NoConnectException(e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user