Commit c46ff431 authored by zeroleak's avatar zeroleak
Browse files

fix potential memory leak

parent e180e6ee
// TODO SAMOURAI FIX https://github.com/thaliproject/Tor_Onion_Proxy_Library/pull/124
// TODO SAMOURAI FIX https://github.com/thaliproject/Tor_Onion_Proxy_Library/pull/132
/*
Copyright (c) Microsoft Open Technologies, Inc.
All Rights Reserved
......@@ -51,13 +52,20 @@ public final class TorConfigBuilder {
}
private static boolean isLocalPortOpen(int port) {
Socket socket = null;
try {
Socket socket = new Socket();
socket = new Socket();
socket.connect(new InetSocketAddress("127.0.0.1", port), 500);
socket.close();
return true;
} catch (Exception e) {
return false;
} finally {
if (socket != null) {
try {
socket.close();
} catch (Exception ee) {
}
}
}
}
......
......@@ -176,6 +176,9 @@ public class TorOnionProxyInstance implements JavaTorConnexion {
private CliProxy getTorSocksOrNull() {
if (torSocks == null) {
try {
if (log.isDebugEnabled()) {
log.debug("Looking for TorSocks...");
}
int socksPort = onionProxyManager.getIPv4LocalHostSocksPort();
torSocks = new CliProxy(CliProxyProtocol.SOCKS, "127.0.0.1", socksPort);
log.info("TorSocks started: " + torSocks);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment