summaryrefslogtreecommitdiff
path: root/jurt/com
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-08-19 11:26:58 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-08-19 13:00:44 +0100
commitce757cdd9e68193ad08bffc0911f72e7cd3dc283 (patch)
tree3574104d6b72c8e9a20e0c5a716def3366bc55d3 /jurt/com
parent29a479c3ceada7343974730c8c9eeaea0a5c9d1f (diff)
coverity#1371380 Resource leak on an exceptional path
Change-Id: I278f8d50dfaaa45e582a34e43ddba3b143203796
Diffstat (limited to 'jurt/com')
-rw-r--r--jurt/com/sun/star/lib/connections/socket/socketAcceptor.java8
-rw-r--r--jurt/com/sun/star/lib/connections/socket/socketConnector.java8
2 files changed, 12 insertions, 4 deletions
diff --git a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
index 9fd8001262aa..4000a1d0a463 100644
--- a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
+++ b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java
@@ -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);
}
}
diff --git a/jurt/com/sun/star/lib/connections/socket/socketConnector.java b/jurt/com/sun/star/lib/connections/socket/socketConnector.java
index e88f1040ac16..3d29e47f4f21 100644
--- a/jurt/com/sun/star/lib/connections/socket/socketConnector.java
+++ b/jurt/com/sun/star/lib/connections/socket/socketConnector.java
@@ -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);
}