free native WOLFSSL when WolfSSLSocket is closed, earlier than finalize

pull/69/head
Chris Conlon 2021-09-29 13:54:13 -06:00
parent 30e7ec6f03
commit cda657839b
1 changed files with 8 additions and 0 deletions

View File

@ -1371,6 +1371,12 @@ public class WolfSSLSocket extends SSLSocket {
synchronized (handshakeLock) {
this.connectionClosed = true;
/* Connection is closed, free native WOLFSSL session
* to release native memory earlier than garbage collector
* might with finalize(). */
this.ssl.freeSSL();
this.ssl = null;
}
}
@ -1396,6 +1402,8 @@ public class WolfSSLSocket extends SSLSocket {
} catch (IllegalStateException e) {
throw new IOException(e);
} catch (WolfSSLJNIException jnie) {
throw new IOException(jnie);
}
}