Skip to content

Commit 405f3a4

Browse files
authored
Fix crash in Quiche when calling isClosed on freed connections (#798)
Motivation: When QuicheQuicConnection is freed, it sets the connection reference to -1. Unfortunately, it's possible to then inspect the native closed state of this connection, which will crash in Quiche. Modification: Change the `assert connection != -1` to a real conditional in `isClosed`, to avoid calling into Quiche on freed connections. Result: This fixes a JVM crash bug with our QUIC codec.
1 parent 5d0ea1c commit 405f3a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicheQuicConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ final class QuicheQuicConnection {
6060
private long connection;
6161

6262
QuicheQuicConnection(long connection, long ssl, QuicheQuicSslEngine engine, ReferenceCounted refCnt) {
63+
assert connection != -1;
6364
this.connection = connection;
6465
this.ssl = ssl;
6566
this.engine = engine;
@@ -216,8 +217,7 @@ boolean isSendInfoChanged() {
216217
}
217218

218219
boolean isClosed() {
219-
assert connection != -1;
220-
return Quiche.quiche_conn_is_closed(connection);
220+
return isFreed() || Quiche.quiche_conn_is_closed(connection);
221221
}
222222

223223
// Let's override finalize() as we want to ensure we never leak memory even if the user will miss to close

0 commit comments

Comments
 (0)