Ensure OpenSslEngine will not try to call SSL_free multiple times even when constructor throws. (#8399)
Motivation: When the constructor of OpenSslEngine threw we could end up to self call SSL_free by ourself and then have the finalizer do the same which may lead to double free-ing and so SIGSEV. Modifications: Just call shutdown() when the constructor throws and so ensure SSL_free is guarded correctly in the finalizer. Result: No more SIGSEV possible.
This commit is contained in:
parent
2109f14c24
commit
3543e17967
@ -363,7 +363,11 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc
|
||||
// setMode may impact the overhead.
|
||||
calculateMaxWrapOverhead();
|
||||
} catch (Throwable cause) {
|
||||
SSL.freeSSL(ssl);
|
||||
// Call shutdown so we are sure we correctly release all native memory and also guard against the
|
||||
// case when shutdown() will be called by the finalizer again. If we would call SSL.free(...) directly
|
||||
// the finalizer may end up calling it again as we would miss to update the DESTROYED_UPDATER.
|
||||
shutdown();
|
||||
|
||||
PlatformDependent.throwException(cause);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user