GeezerVison is showing github.com — Auto-port 4.1: SslHandler: Fix possible buffer leak when an OOME is t… · lltopk/netty@f0b0358
File tree
Expand file treeCollapse file tree
Open diff view settings
handler/src/main/java/io/netty/handler/ssl
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/SslHandler.java +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -849,7 +849,7 @@ private void wrap(ChannelHandlerContext ctx, boolean inUnwrap) throws SSLExcepti |
849 | 849 | break; |
850 | 850 | } |
851 | 851 |
|
852 | | - SSLEngineResult result; |
| 852 | + SSLEngineResult result = null; |
853 | 853 |
|
854 | 854 | try { |
855 | 855 | if (buf.readableBytes() > MAX_PLAINTEXT_LENGTH) { |
@@ -874,16 +874,16 @@ private void wrap(ChannelHandlerContext ctx, boolean inUnwrap) throws SSLExcepti |
874 | 874 | } |
875 | 875 | result = wrap(alloc, engine, buf, out); |
876 | 876 | } |
877 | | - } catch (SSLException e) { |
878 | | - // Either wrapMultiple(...) or wrap(...) did throw. In this case we need to release the buffer |
879 | | - // that we removed from pendingUnencryptedWrites before failing the promise and rethrowing it. |
880 | | - // Failing to do so would result in a buffer leak. |
| 877 | + } catch (Throwable e) { |
| 878 | + // Either wrapMultiple(...), wrap(...) or allocateOutNetBuf(...) did throw. |
| 879 | + // In this case we need to release the buffer that we removed from pendingUnencryptedWrites |
| 880 | + // before failing the promise and rethrowing it. Failing to do so would result in a buffer leak. |
881 | 881 | // See https://github.com/netty/netty/issues/14644 |
882 | 882 | // |
883 | 883 | // We don't need to release out here as this is done in a finally block already. |
884 | 884 | buf.release(); |
885 | 885 | promise.setFailure(e); |
886 | | - throw e; |
| 886 | + PlatformDependent.throwException(e); |
887 | 887 | } |
888 | 888 |
|
889 | 889 | if (buf.isReadable()) { |
|